微信小程序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,但是获取的时候会转换成小写字母
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM