如下所示:
{{btn_text1}}
{{btn_text2}}
var _vm = new Vue({
data : {
btn_text1 : '點擊1' ,
btn_text2 : '點擊2'
},
methods : {
test_click1 : function (e) {
console.log('test_click1--------------------------') ;
console.log(e) ;
// 輸出結果:MouseEvent {isTrusted: true, screenX: 40, screenY: 121, clientX: 40, clientY: 30, …}
console.log(e.target) ; // 輸出結果:點擊1
console.log('test_click1--------------------------') ;
},
test_click2 : function (e) {
console.log('test_click2--------------------------') ;
console.log(e) ; // 輸出結果:123
console.log(e.target) ; // 輸出結果:undefined
console.log('test_click2--------------------------') ;
}
}
}).$mount('#app');
以上這篇對vue下點擊事件傳參和不傳參的區別詳解就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。