mark是小程序基础库版本 2.7.1 以上新出的标签属性
该属性的作用是将所有mark绑定的数据进行合并,类似于自定义属性dataset
直接上例子
<view mark:myMark="last" bindtap="bindViewTap">
<button mark:anotherMark="leaf" bindtap="bindButtonTap">按钮</button>
</view>
Page({
bindViewTap: function(e) {
e.mark.myMark === "last" // true
e.mark.anotherMark === "leaf" // true
}
})
用es6语法解构 装逼一点
Page({
bindViewTap: function(e) {
const { myMark } = e.mark
console.log(`$(myMark)`)
}
})