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