vue-cli project, after packing js, css, img static resources can not be found
js, css resources can not be found
最近,我使用vue-cli脚手架搭建了一个vue项目框架,随意写了点页面,打包出来之后,放到tomcat运行,
MOG,竟然所有的资源都找不到,全是404。通过查看api和别人的博客,修改了一下配置文件,config.js下的index.js
默认的时候,是没有monitor的,记得assetsPublicPath前后都是有斜杠的,别弄错了哟,
npm run build 之后,dist目录下会多一层monitor文件夹,再下面才是static和index.html.
After modification, js and css file resources finally found. But there was another problem, can not find the image resource
在Vue项目中通过data设置图片路径,然后在template中引入后页面无法显示图片,浏览器控制台报错:
刚开始以为是路径出问题了,于是绝对路径、相对路径各种办法试了一遍,发现还是报错,后来才发现这是
因为在Vue里动态生成的路径无法被url-loader解析到,此时有两种解决方法:
Method One picture directly to your source file in the project directory of static folder, and then write the image path as normal written on it:
Method 2 by means of the image import source path is introduced, as shown below:
Transfer:
https://www.jianshu.com/p/9a4690f5bdce