给元素设置背景图,地址从data数据里拿,为什么会报错找不到图片呢?
发布于 6 年前 作者 dwang 6032 次浏览 来自 问答
  • 需求的场景描述(希望解决的问题)
<view wx:for='{{name_tel}}'>
    <label for='{{item.id}}' style="background-image:url({{item.imgUrl}})"></label>
    <input id='{{item.id}}' type='text' placeholder='{{item.placeholder}}'></input>
  </view>
  • 希望提供的能力

这里label的背景图地址找不到,报错为:

Failed to load local image resource /pages/index/images/smapp_name.png 

 the server responded with a status of 404 (HTTP/1.1 404 Not Found) 

1 回复

解决了,是图片路径的问题,图片地址前加…/…/就可以了

回到顶部