Javascript 防止在以角度加载组件时更改无线电值时出错
请帮助我尝试使用单选按钮设置日期,但在加载组件时更改值时出错 html.component.htmlJavascript 防止在以角度加载组件时更改无线电值时出错,javascript,angular,typescript,radio-button,Javascript,Angular,Typescript,Radio Button,请帮助我尝试使用单选按钮设置日期,但在加载组件时更改值时出错 html.component.html 。。。 1周 1个月 三个月 6个月 ... html.component.ts 。。。 AsperioDBTN='1W'; ... ngAfterViewInit(){ 本设定日期('1M'); } 设定日期(期间){ this.asPeroidBtn=周期; } ... 通过使用此选项,我得到了一个错误: ERROR Error: ExpressionChangedAfterItHasB
。。。
1周
1个月
三个月
6个月
...
html.component.ts
。。。
AsperioDBTN='1W';
...
ngAfterViewInit(){
本设定日期('1M');
}
设定日期(期间){
this.asPeroidBtn=周期;
}
...
通过使用此选项,我得到了一个错误:
ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for 'checked': 'true'. Current value: 'false'.
at throwErrorIfNoChangesMode (core.js:5625)
at bindingUpdated (core.js:13962)
at Module.ɵɵproperty (core.js:14706)
at GNB5100Component_Template (html.component.html:36)
at executeTemplate (core.js:7449)
at refreshView (core.js:7318)
at refreshComponent (core.js:8465)
at refreshChildComponents (core.js:7126)
at refreshView (core.js:7368)
at refreshEmbeddedViews (core.js:8419)
请帮助修复此错误。将ngAfterViewInit更改为ngAfterContentInit,错误将不会发生 有关更多信息,请在此处查看此答案
为什么不能将AsperioDBTN值默认设置为“1M”?@PiyushJain我有其他理由将此默认设置为“1W”,但在某些情况下,我需要将其设置为“1M”,但如果我将其设置为“1M”,则会出现错误。谢谢您的回答,非常好