Vue项目打包后访问静态资源无法直接访问,路由无法跳转

问题原因,打包之后访问路径错误,index.html打开是空白

解决方案

步骤1,修改使用路由方式
将路由从history换成hash

const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes
});

步骤2,修改使用配置文件

module.exports = {
    // 解决不引用就会报错
    lintOnSave: false,
    publicPath: "./",
}

然后打包,再访问,问题就解决了

感谢您赏阅

posted on 2022-06-23 23:45  铃之森  阅读(2617)  评论(0编辑  收藏  举报

导航