VUE mode为history页面为空白

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Zhooson/article/details/81951723

当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,刷新页面就好了

猜你喜欢

转载自blog.csdn.net/Zhooson/article/details/81951723