VUE 解决mode为history页面为空白的问题

当router.js 中mode:history 发现刷新页面 不显示了,原因出来history的请求路径资源不存在了,这个需要后端配置的, 前端 需要修改一个地方即可, devServer: { port: 8000, h...

当router.js 中mode:history 发现刷新页面 不显示了,原因出来history的请求路径资源不存在了,这个需要后端配置的,

前端 需要修改一个地方即可,

   devServer: {
      port: 8000,
      host: '0.0.0.0',
      overlay: {
        errors: true
      },
      hot: true,
      historyApiFallback: {
        index: '/index.html'
      }
    },

新增historyApiFallback这个个功能,然后的index的路径需要配置output输出的Publicpath的配合使用

publicPath:'/public/'

对应的路径 index:'/public/index.html'

重启webpack,刷新页面就好了

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
admin
admin

651 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. bngvitmrbj 0 文章