经常在循环中这样写:
< view wx:for = "{{array}}" wx:key = "ID" bindtap = "itemTap" class = 'list' > ……………… < text data-index = "{{index}}" data-id = "{{item.ID}}" catchtap = 'aaa' >修改</ text >
</ view > |
但总觉得这样写太啰嗦,有没有可能,只在最上层写一次data-index
=
"{{index}}"
data-id
=
"{{item.ID}}"
,下面节点绑定的事件都能获取到index和ID,如下:
< view wx:for = "{{array}}" wx:key = "ID" bindtap = "itemTap" class = 'list' > ……………… < text catchtap = 'aaa' >修改</ text > < text catchtap = 'bbb' >操作一</ text > < text catchtap = 'ccc' >操作二</ text > < text catchtap = 'ddd' >操作三</ text > ………… </ view > |
没人回答一下吗