在一些場景中,我們需要獲取到標簽里面的值來和接口返回的值做對比,一致則進行下一步,后者進行錯誤判斷
<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);
? ? },