给出以下代码:
父组件:
<my-cmp readonly></my-cmp>
子组件:
...
constructor(@Attribute('readonly') readonly) {
this._readonly = readonly !== null ? 1 : 0;
}
...
如何检测readonly属性的更改?
答案 0 :(得分:1)
@Input()
set readonly(val) {
if(val === '') {
console.log('set');
} else {
console.log('removed');
}