本地缓存数据如下:
deviceList:[
{deviceName:'设备A',deviceId:'a',selStatus:false},
{deviceName:'设备B',deviceId:'b',selStatus:false},
{deviceName:'设备C',deviceId:'c',selStatus:true}
]
1
2
3
4
5
1
2
3
4
5
现在将设备A项选为当前设备:
index.wxml:
<view class="device-list" wx:for="{{deviceList}}" wx:for-item="item" wx:key="item">
<view class="device_name">{{item.deviceName}}</view>
<button bindtap="setCurDevice" data-id="{{item.deviceId}}" disabled="{{item.selStatus ? true : false}}"
class="selectCur" type="{{item.selStatus ? 'default' : 'primary'}}">{{item.selStatus ?'当前设备':'选为当前设备'}}</button>
</view>
1
2
3
4
5
1
2
3
4
5
index
在缓漏一些场景中,我们需要获取到标签里面的塌裤值团哪简来和接口返回的值做对比,一致则进行下一步,后者进行错误判断
<block wx:for='{{objectArray}}' data-name='{{item.name}}' data-id='{{item.id}}' bindtap='select'>
<text class='yuzhong'>{{item.name}}</text>
</view>
主要在于 data- 这个上面 上面的那个name 和 id 是我自己定义的,你们可以随意定义一些语义化的词,
获取也很简单:
select:function(e){
console.log(e.currentTarget.dataset.name)
},
您好,可以这样设置:
function setData(){var that = this
弯伍 that.setData({
smart_cookies_city:'134',
做顷 cityname:'南京'埋胡或
})
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)