js --onclickjquery--clickvue--@clickReact--onClickAngular--(click)
# app.component.tsimport { Component } from '@angular/core';@Component({ //根主键 selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css']})export class AppComponent { title = 'my-app'; handleClick():void{ console.log("click"); }}# app.component.html<div (click)="handleClick()">{{title}}</div>
2-1. 通过事件获取this.title中的数据
# app.component.ts)export class AppComponent { title = 'my-app'; handleClick():void{ console.log(this.title); }}# app.component.html<div (click)="handleClick()">{{title}}</div>
2-2. 通过事件改变this.title中的数据
# app.component.tsexport class AppComponent { title = 'my-app'; handleClick():void{ this.title = 'wang' }}# app.component.html<div (click)="handleClick()">{{title}}</div>