如果为空,则不显示奖励这两个字的标签
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