小程序我前端循环渲染,如何把渲染的组件在点击时传递数据给js?
js-->携带数据,并且循环渲染给每个组件--->组件绑定bindtap事件,在点击该组件时,把该组件的数据,传到bindtap事件函数
可以在组件上绑定上需要传递的数据
例如
<view data-type=
"{{item.type}}"
bindtap=
"test"
>test<view>
test(e){
let _type = e.currentTarge.dataset,type;
}
取值如上述函数。