Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

偶尔有 Cannot read 'setContent' of undefined 错误 #10

Closed
BenzLeung opened this issue Jun 2, 2018 · 0 comments
Closed

偶尔有 Cannot read 'setContent' of undefined 错误 #10

BenzLeung opened this issue Jun 2, 2018 · 0 comments
Assignees
Labels

Comments

@BenzLeung
Copy link

this.zone.runOutsideAngular(() => {
window.UMEDITOR_CONFIG.UMEDITOR_HOME_URL = this.path;
let umeditor = UM.getEditor(this.id, Object.assign({
UMEDITOR_HOME_URL: this.path
}, this.config, options));
umeditor.addListener('contentChange', () => {
this.updateValue(umeditor.getContent());
});
this.zone.run(() => {
this.instance = umeditor;
});
});
// ready 只会在UM首次加载时触发,倒置 [(ngModel)] 失效
setTimeout(() => {
this.value && this.instance.setContent(this.value);
this.onReady.emit(this);
}, 300);

在大项目中,偶尔莫名其妙出现 Cannot read 'setContent' of undefined 错误。

建议把行90-94,整个 setTimeout 语句移入行 85 this.instance = umeditor; 之后面。

@cipchk cipchk added the bug label Jun 2, 2018
@cipchk cipchk self-assigned this Jun 2, 2018
@cipchk cipchk closed this as completed in ab21278 Jun 3, 2018
cipchk added a commit that referenced this issue Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants