微信小程序bindTap获取对应值

<button bindtap="btn" id="hello" data-cnName="你好" data-name="{{name}}">Button按钮</button>

data:{
name: '名字 '
},
btn(e){
console.log(e.currentTarget.id); // 'hello'
console.log(e.currentTarget.dataset.cnname); '你好' 这里需要注意wxml页面绑定的是cnName,但是获取的时候会转换成小写字母
}

原文地址:https://www.cnblogs.com/riyueqian/p/13150604.html