Vue Js 2错误重新加载

Vue Js 2 error reload

我正在使用 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 路由器 link 或 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 配置 nginx 服务器,该服务器适用于 apache

尝试配置 nginx,配置如下:

location / {
  try_files $uri $uri/ /index.html;
}

我通过添加 .htaccess 并转换为 nginx 代码并在脚本标记的 src 属性中添加斜杠“/”解决了这个问题

 <script src="/dist/app.js">