vue事件處理機制


<button @click="handleAdd1()">add1</button>
<button @click="handleAdd2">add2</button>
<button @click="count++">add3</button>

不帶括號可以直接傳一個事件對象

 

帶括號的可以傳參。

<input type="text" @input="handleInput($event)" @keyup.65="handleKeyUp"/>

handleInput(ev){
  console.log(ev.target.value);
  this.mytext= ev.target.value;
}

 

還可以搞$event,加傳參

<input type="text" @input="handleInput($event,param)" @keyup.65="handleKeyUp"/>

handleInput(ev,param){
  console.log(ev.target.value);
  this.mytext= ev.target.value;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM