1、在vue.config.js中添加
devServer: {
historyApiFallback: true,
allowedHosts: "all",
client: {
overlay: false,
},
},
2、完整代码
const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
transpileDependencies: true,
publicPath: process.env.NODE_ENV === "production" ? "./" : "/", // 配置打包路径
lintOnSave: false, // 这里禁止使用eslint-loader
productionSourceMap: false, // 生产环境是否生成 sourceMap 文件,一般情况不建议打开
devServer: {
historyApiFallback: true,
allowedHosts: "all",
// 解决报错覆全屏
client: {
overlay: false,
},
},
});