Angular事件绑定

作者: readilen | 来源:发表于2018-04-15 09:54 被阅读15次

    目前Angular 5 支持的事件

    (focus)="myMethod()"  // An element has received focus
    (blur)="myMethod()"   // An element has lost focus
    
    (submit)="myMethod()"  // A submit button has been pressed
    
    (scroll)="myMethod()"
    
    (cut)="myMethod()"
    (copy)="myMethod()"
    (paste)="myMethod()"
    
    (keydown)="myMethod()"
    (keypress)="myMethod()"
    (keyup)="myMethod()"
    
    (mouseenter)="myMethod()"
    (mousedown)="myMethod()"
    (mouseup)="myMethod()"
    
    (click)="myMethod()"
    (dblclick)="myMethod()"
    
    (drag)="myMethod()"
    (dragover)="myMethod()"
    (drop)="myMethod()"
    

    組件模板中的使用方法

    <button (click)="myEvent($event)">My Button</button>
    

    組件中

    export class AppComponent {
      
      myEvent(event) {
        console.log(event);
      }
    
    }
    

    事件类型一览表

    相关文章

      网友评论

        本文标题:Angular事件绑定

        本文链接:https://www.haomeiwen.com/subject/qccdkftx.html