We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Onchanges
import { Input, OnChanges, SimpleChanges } from '@angular/core'; ... export class xxx implements OnChanges { @Input() title: string; ngOnChanges(sc: SimpleChanges) { if('title' in sc){ // 需要做存在判断才能使用 // sc.title.currentValue --> 最新的值,做一些处理逻辑 } } }
import { Input } from '@angular/core'; ... export class xxx implements OnChanges { _title: string; @Input() get title() { return this._title; } set title(value) { // 做一些处理逻辑 this._title = value; } }
==传过来的值若为引用类型,只是改变属性,引用不变上述方法均不会触发,建议传过来的时候深拷贝一下==
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1.
Onchanges
生命周期2. get、set
==传过来的值若为引用类型,只是改变属性,引用不变上述方法均不会触发,建议传过来的时候深拷贝一下==
The text was updated successfully, but these errors were encountered: