小程序事件代理
<view class="tool-list" catchtap="toolTapped"> <view class="tool-list__item data-to="{{ ... }}" wx:for="{{ tools }}"> <view class="tool-list__btn"> <text class="tool-list__icon"></text> <text class="tool-list__label"></text> </view> </view></view> |
tool-list 下面会有多个 tool-list__item,每一个 tool-list__item 的 data-to 是不一样的,上面代码中如果点击事件在 tool-list__item 下面任意一个子元素触发是无法拿到 data-to 的,如果想要触发我就要在 tool-list__btn tool-list__icon tool-list__label 上全部写上 data-to,不知道有没有其他的解决方案
