なぜ私は定義されていないエラーが発生するのか分かりません。これは私が取得エラーメッセージが表示されます。「例外TypeError:未定義の設定はできませんプロパティ 『状態』」定義されていないエラー角度2クラス
は、これは私のコードです:
export class MobileMenuComponent implements OnInit {
menu: any;
constructor() {
}
ngOnInit() {
this.menu.state = 'inactive';
this.menu.togglemenu = function() {
if (this.menu.state === 'inactive'){
this.menu.state = 'active';
}
else {
this.menu.state = 'inactive';
}
}
}
}
あなたはメニューを宣言したが、そのまだ未定義 – Noppey
'menu'はany''に設定されますが、 'any'は' undefined'です。 – TW80000