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文件,自然找到了

相关文章:

  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-03-31
  • 2022-12-23
  • 2021-04-02
相关资源
相似解决方案