我已经阅读了其他条目,但我仍然不知道如何解决我的问题 . 问题是下一个问题:
TypeError:无法在Object.eval [as updateRenderer](ng:///AppModule/MyApp.ngfactory.js:105:62)的Object.debugUpdateRenderer [作为updateRenderer]读取未定义的属性'state'(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)在checkAndUpdateView(http:// localhost:8100 / build / vendor.js:13867:5)的execComponentViewsAction(http:// localhost:8100 / build / vendor.js:14143:13)上的callViewAction (http:// localhost:8100 / build / vendor.js:14211:21)在checkAndUpdateView(http:// localhost:8100)的execEmbeddedViewsAction(http:// localhost:8100 / build / vendor.js:14169:17) /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 .
1 回答
对我来说,错误来自于此:
您的服务中有
this._state
而不是this.state