我使用下面的代码为侧边菜单超过两年,直到离子版本5现在更新离子到6.20.6和Angular 15^我得到下面的错误在
否则{此显示级别1 = idx;*
类型“string”不能赋给类型“null”。ts(2322)
export class AppComponent {
public appPages: any;
showLevel1 = null;
showLevel2 = null;
@ViewChildren(IonRouterOutlet) routerOutlets: QueryList<IonRouterOutlet>;
clearLevel() {
this.showLevel1 = null;
this.showLevel2 = null;
// this.showLevel3 = null;
}
toggleLevel1(idx: string) {
if (this.isLevel1Shown(idx)) {
this.showLevel1 = null;
} else {
this.showLevel1 = idx;
}
}
isLevel1Shown(idx: string) {
return this.showLevel1 === idx;
}
1条答案
按热度按时间jpfvwuh41#
最新的ionic嵌入了字符串类型。如果要将变量/成员变量用作字符串,请分配空字符串。例如,