angular2出现值变化没有立即更新到ui上

2018-08-20 11:17:26 浏览数 (1)

解决方法

代码语言:javascript复制
import { Component, OnInit,NgZone } from '@angular/core';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {

  querys = 2323;

  constructor(private ngzone:NgZone) { }

  ngOnInit() {
  }

  set() { 
    this.ngzone.run(() => { 
      this.querys = 5;
    })
  }

}

0 人点赞