【已解决】vue打包部署处理静态资源问题,出现空白页,background资源路径不对

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39403545/article/details/82192213

1 vue项目把打包后的dist文件放到服务器上访问出现空白页

错误原因:js和css资源的路径不正确

解决方法:将config/index.js中的assetsPublicPath: '/'改为assetsPublicPath: './'

2 vue项目访问背景图片没有加载出来

错误url:http://localhost:8080/dist/static/css/static/img/login_bg.61563c2.png

正确url:http://localhost:8080/dist/static/img/login_bg.61563c2.png (多了两层/static/css)

错误原因:css中引用的图片资源找不到(不包括<img>引用的图片)

解决方法:在build/utils.js中增加一行代码 publicPath:'../../'

参考:http://www.ftc20.com/wordpress/2017/11/vue-static-resource-route-question/?lwruhe=t355e1

猜你喜欢

转载自blog.csdn.net/qq_39403545/article/details/82192213