vue项目使用历史模式后刷新页面出现空白页

301 阅读1分钟

vue项目使用历史模式后刷新页面出现空白页,需要在vue.cofing.js下设置路由模式为历史模式 加上这一句代码

historyApiFallback: true,//设路由模式为历史模式需要的配置

publicPath: "./",
outputDir: "dist",
devServer: {
    historyApiFallback: true, //设路由模式为历史模式需要的配置
    port: 9189,
    open: true,
    proxy: {
        "/api": {
            target: "http://localhost:9020",
            changeOrigin: true,
            pathRewrite: {
                "^/api": "",
            },
        },
    },
},

同时如果路由中包含子路由必须在index.html中加上