[渲染层网络层错误] Failed to load local image resource /page/login/undefined the server responded with a status of 500
使用uni-app开发微信小程序,在HBuilder和微信开发者工具图片都显示正常,但是在微信开发者工具编译加载图片时,报图片为undefined
原因:页面初次加载时,图片还没加载出来,为空,使用计算属性Compute()解决。
- 使用页面HTML代码
<view class="topbox " :style="{backgroundImage: bgImage}"></view>
- 使用Computed()
computed: {
bgImage() {
return 'url('+require('@/static/icon/register/bg03.png')+')'
}
},