如果為空,則不顯示獎勵這兩個字的標簽
wxml
<view class="cu-item" wx:for="{{allSignList}}" wx:key="index"> <view class="content"> <view wx:if="{{item.taskReward}}">獎勵:{{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": "獎勵一個小星星" }, { "taskId": 2, "taskReward": "獎勵一塊糖" }, { "taskId": 3, "taskReward": "" } ] }
顯示:
本文摘自 :https://blog.51cto.com/u