vue项目打包后页面空白

原因:打包后的dist目录下的文件引用路径不对,会因找不到文件而报错导致白屏。
解决办法:修改一下config下面的index.js中bulid模块导出的路径。因为index.html里边的内容都是通过script标签引入的,而你的路径不对,打开肯定是空白的。先看一下默认的路径。
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
productionSourceMap: true
assetsPublicPath默认的是  ‘/’  也就是根目录。而我们的index.html和static在同一级目录下面。  所以要改为  ‘./ ’;
 
注意:一定是bulid模块下assetsPublicPath

猜你喜欢

转载自www.cnblogs.com/aoshuang/p/10700494.html