npm run build
把我的第一个大Vue3应用程序带到真实的服务器测试驱动器上。
所以我得到了这些文件,上传到我的VPS中,然后惊奇地发现:只有当我通过点击导航时,服务器才能识别路由路径。
https://next.router.vuejs.org/guide/essentials/history-mode.html
给我的
.htaccess
文件(我在Centos 7上使用apache
但问题仍然存在,唯一的区别是它不是抛出错误,而是陷入了
index.html
我正在定义
main.js
文件,如下所示:
import { createRouter, createWebHistory } from "vue-router"
import Page from "./views/Page.vue"
import Content from "./views/Content.vue"
import BaseSection from "./components/BaseSection.vue"
//ROUTER
const router = createRouter({
history: createWebHistory(),
routes: [{
path: "/",
name: "Home",
component: Page,
meta: {
title: 'Home'
}
},
{
path: "/docs/1.0/:title",
component: Content,
name: "docs"
}
],
scrollBehavior(to) {
if (to.hash) {
return {
el: to.hash,
behavior: 'smooth',
}
}
}
});
app.use(router);
谢谢您。
当做,
T。