【发布时间】:2018-10-14 03:05:44
【问题描述】:
我正在使用 Vue Js 2,服务器是 Nginx。
我有下一个代码:
const routes = [
{
path: '/design-dashboard',
component: DesignDashboard,
meta: {
forAuth : true
}
},
{
path: '/dashboard/new/create',
component: ProductLineEdit,
meta: {
forAuth : true
}
}
];
export default new VueRouter({
mode: 'history',
routes
});
问题是当 url 有超过 1 个部分 o 斜杠“/”时,例如它适用于“/design-dashboard”,而不适用于“/dashboard/new/create”只能通过vue路由器链接或者router.push()方法,但是当我重载或者尝试用浏览器中的url直接访问时不起作用。
我还添加了这个 htaccess 代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
正如我之前所说,只有一个部分或斜线'/ 就可以正常工作,例如“/design-dashboard”
有什么想法吗?提前致谢。
【问题讨论】:
标签: vue.js vuejs2 vue-router