如果為空,則不顯示獎(jiǎng)勵(lì)這兩個(gè)字的標(biāo)簽
wxml
<view class="cu-item" wx:for="{{allSignList}}" wx:key="index"> <view class="content"> <view wx:if="{{item.taskReward}}">獎(jiǎng)勵(lì):{{item.taskReward}}</view> </view> </view>
js
Page({ data: { allSignList: [] }, onLoad: function (options) { wx.request({ url: 'http://www.xxx.com/1.json', header: { 'content-type': 'application/json' }, success: res => { this.setData({ allSignList:res.data.data }) } }) }, })
json
{ "msg": "操作成功", "code": "0000", "data": [ { "taskId": 1, "taskReward": "獎(jiǎng)勵(lì)一個(gè)小星星" }, { "taskId": 2, "taskReward": "獎(jiǎng)勵(lì)一塊糖" }, { "taskId": 3, "taskReward": "" } ] }
顯示:
本文摘自 :https://blog.51cto.com/u