VueJS和Firebase,刷新时的历史模式404错误

eQu*_*nox 8 http-status-code-404 firebase vue.js vuejs2 vuefire

我在路由器文件中删除了历史模式链接中的hashbang.现在,当我刷新页面时,我收到了404错误.

我试着按照这个链接

然后,我在firebase.json中添加了部分:

{
  "hosting": {
    "public": "dist",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

然而一切都没有改变.

我不明白为什么我还有这个错误.我尝试了很多东西,但我找不到解决它的东西.

这是我的路由器文件:

const router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      redirect: '/catalog'
    },
    {
      path: '/catalog',
      name: 'Catalog',
      component: Catalog
    },
    {
      path: '/catalog/category/:category',
      name: 'ProductsList',
      component: ProductsList
    },
    {
      path: '/catalog/category/:category/product/:id',
      name: 'ProductDetail',
      component: ProductDetail,
    },
    {
      path: '/catalog/category/:category/product/create',
      name: 'CreateProduct',
      component: CreateProduct
    }
  ]
});
Run Code Online (Sandbox Code Playgroud)

Phi*_*hil 0

我唯一能想到的是您尚未将更改部署到您的firebase.json文件中。

执行

firebase deploy --only hosting
Run Code Online (Sandbox Code Playgroud)

您应该能够从项目的托管页面查看部署历史记录。确认更改已部署。