微信小程序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