1. wechat-- onLoad
  2. vue -- mounted
  3. React --componentDidMount
  4. Angular--ngOnInit
  1. //app.component.html
  2. <div (click)="handleClick()">{{title}}</div>
  1. //app.component.ts
  2. export class AppComponent {
  3. title = 'my-app';
  4. handleClick():void{
  5. console.log("click")
  6. }
  7. }

通过事件获取data中的数据

  1. export class AppComponent {
  2. title = 'my-app';
  3. handleClick():void{
  4. this.title="change"
  5. console.log(this.title)
  6. }
  7. }

通过事件改变data中的数据

  1. export class AppComponent {
  2. title = 'my-app';
  3. handleClick():void{
  4. this.title="change"
  5. }
  6. }