webpack4+Vue-cli3打包后index.html空白,报We’re sorry but template doesn’t work properly without JavaScript enabled. Please enable it to continue问题解决


1、问题代码:vue.config.js中publicPath: './', (相对路径)且配置了pages和路由是history模式,

// vue.config.js
module.exports = {
    publicPath: './',
    pages: {
        index: {
            entry: ["node_modules/core-js", "src/main.ts"],
        },
    },
    devServer: {
        ...
    },
};

2、问题原因:

     相对路径的 publicPath 有一些使用上的限制。在以下情况下,应当避免使用相对 publicPath:

  • 当使用基于 HTML5 history.pushState 的路由时;

  • 当使用 pages 选项构建多页面应用时。

3、修改方案:

删除vue.config.js的page配置,修改路由模式为hash

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM