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

标签 firebase vue.js vuejs2 http-status-code-404 vuefire

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

我试着关注 this link

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

{
  "hosting": {
    "public": "dist",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

但是什么都没有改变。

我不明白为什么我仍然有这个错误。 我尝试了很多方法,但找不到解决方法。

这是我的路由器文件:

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
    }
  ]
});

最佳答案

我唯一能想到的是您还没有将更改部署到您的 firebase.json 文件。

执行

firebase deploy --only hosting

您应该能够从项目的 Hosting page 查看部署历史记录.确认更改已部署。

关于firebase - VueJS 和 Firebase,刷新时历史模式 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47284306/

相关文章:

android - Firebase - 强制使用唯一的用户名

vue.js - 如何让我的基本网址在 Vue/Cli 中更改

javascript - 如何在 Bootstrap 选项卡中创建多个 Vue 组件?

vue.js - 如何在 Vue JS SPA 中打开图形图像?

javascript - Vuejs - 未在实例上定义计算属性

node.js - 从运行在不同端口的 Vue 应用程序调用 Node 快速服务器 API

java - Firestore 根据条件执行删除

ios - 如何在 iOS 上使用 Firebase 取消 Nest ETA?

javascript - 通过键字符串从对象数组中删除属性

ios - iOS 的 Firebase 云消息传递统计信息