【发布时间】:2018-06-01 19:17:21
【问题描述】:
我已经阅读了其他条目,但我仍然不知道如何解决我的问题。问题是下一个:
TypeError:无法读取未定义的属性“状态” 在 Object.eval [作为 updateRenderer] (ng:///AppModule/MyApp.ngfactory.js:105:62) 在 Object.debugUpdateRenderer [作为 updateRenderer] (http://localhost:8100/build/vendor.js:14730:21) 在 checkAndUpdateView (http://localhost:8100/build/vendor.js:13866:14) 在 callViewAction (http://localhost:8100/build/vendor.js:14211:21) 在 execComponentViewsAction (http://localhost:8100/build/vendor.js:14143:13) 在 checkAndUpdateView (http://localhost:8100/build/vendor.js:13867:5) 在 callViewAction (http://localhost:8100/build/vendor.js:14211:21) 在 execEmbeddedViewsAction (http://localhost:8100/build/vendor.js:14169:17) 在 checkAndUpdateView (http://localhost:8100/build/vendor.js:13862:5) 在 callViewAction (http://localhost:8100/build/vendor.js:14211:21)
还有代码:
import { Injectable } from '@angular/core';
@Injectable()
export class AppState {
_state = {}
constructor() {
}
get state() {
return this._state = this._clone(this._state);
}
set state(value) {
throw new Error('do not mutate the `.state` directly');
}
get(prop?: any) {
const state = this.state;
return state.hasOwnProperty(prop) ? state[prop] : state;
}
set(prop: string, value: any) {
return this._state[prop] = value;
}
_clone(object) {
return JSON.parse(JSON.stringify(object));
}
}
在 Ubuntu 16.04 上使用 Ionic3。
【问题讨论】:
-
您的代码中有错字:
this.state而不是this._state
标签: typescript ionic-framework undefined ionic3