1. 程式人生 > >VUE mode為history頁面為空白

VUE mode為history頁面為空白

當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,重新整理頁面就好了