新手,多多包涵,
打算点击更多信息跳转到详情信息页面,可是却不能获取id,请问是哪里会有问题?
以下是wxml
< block wx:for = "{{test}}" > < van-card title = "{{item['DTC for J1939 SPN']}}|{{item['DTC for J1939 FMI ']}}" desc = "{{item['Chinese Description']}}" > < view slot = "footer" > < van-button type = "info" size = "mini" bindtap = 'moreInfo' >更多信息</ van-button > </ view > </ van-card > </ block > |
<
van-button
type
=
"info"
size
=
"mini"
bindtap
=
'moreInfo'
data-id
=
'{{item.id}}'
>更多信息</
van-button
>
在事件dom上设置 data-xxx属性
然后在事件的第一个参数里可以获得currentTarget.dataset.xxx的属性值
例如<van-button bindtap='getId' data-id='abc' />
getId(e){
console.log(e.currentTarget.dataset.id) // abc
}