mpvue 小程序加载不了图片 Error: Failed to load local image resource /images/xx.png the server responded with a status of 404 (HTTP/1.1 404 Not Found)

mpvue开发小程序时候,要添加静态本地图片

<img src="../../images/bg.png" alt="">

会报错:

VM14878:2 Failed to load local image resource /images/bg.png 
the server responded with a status of 404 (HTTP/1.1 404 Not Found) 

原因有很多种,解决办法可以改webpack,或mpvue的包,这里提供一个非常直接的办法:

直接写 /static/img/xx.png

比如:
<img src="/static/img/bg.png" >

就可以了

原因也很简单,直接存图片放在根目录下的静态资源static文件,自然找到了

posted @ 2018-05-31 17:06  梁凤波  阅读(1877)  评论(0编辑  收藏  举报