例如: post.wxml中
1 2 3 | < block wx:for = "{{postData}}" wx:for-item = "pos" wx:for-index = "idx" wx:key = "postId" > < c-post res = "{{pos}}" index = "{{idx}}" data-post-id = "{{pos.postId}}" bind:tap = "onGoToDetail" /> </ block > |
和在 components > post > index.wxml
1 2 3 | < view class = "post-container" data-post-id = "{{pos.postId}}" bind:tap = "onGoToDetail" > ... </ view > |
表面上两种方法都能实现效果,第二种方法事件绑定更灵活,除了这个还会引起其它什么影响吗?
4年同步微信官方迭代,累计20000+人学习, 比微信官方更火爆!
了解课程