鍍金池/ 問答/HTML5  PHP  HTML/ 微信小程序給label元素設(shè)置背景圖,地址從data數(shù)據(jù)里拿,為什么會(huì)報(bào)錯(cuò)找不到

微信小程序給label元素設(shè)置背景圖,地址從data數(shù)據(jù)里拿,為什么會(huì)報(bào)錯(cuò)找不到圖片呢?


<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的背景圖地址找不到,報(bào)錯(cuò)為:

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)
控制臺(tái)看label結(jié)構(gòu)為:


<labelclass="label-img"for="peopleName"style="background-image:url(images/smapp_name.png)"></label>
回答
編輯回答
朽鹿

解決了,是圖片地址的問題,圖片地址加上../../就可以了

2017年7月5日 12:30