vue.js - Vue Js 2错误重新加载
问题描述
我正在使用 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 个斜杠 '/' 的部分时,例如它适用于“/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”,一切正常
有任何想法吗?提前致谢。
解决方案
似乎您正在尝试配置htaccess
用于apache
.
尝试配置 nginx,配置如下:
location / {
try_files $uri $uri/ /index.html;
}
推荐阅读
- android - Android导航组件如何保存BottomNavigationBar片段状态
- request - 页面加载后的 Web 组件被破坏
- c# - 如何正确地将多个 cv::Mat 从 c++ dll 传递给 opencvsharp Mat c#?
- rest - 使用 REST 的 VSTS NuGet 发布
- illegalaccessexception - 如何通过调用另一个类中对象的方法来打印while循环
- javascript - 无法更改图标图像(反应)
- ruby-on-rails - 创建特定范围HABTM Rails 6
- javascript - React-Router-dom 重定向中断标头链接
- mysql - 本地主机/Joomla 显示“错误”,没有更多信息
- matlab - Inno Setup - 防止桌面快捷方式打开子文件夹,而不是运行同名的可执行文件