如何在SSR中有条件地导入文件@ckeditor/ckeditor5-angular



我被困在Angular Universal/SSR @ckeditor/ckeditor5-angular。当我导入ClassicEditor

import * as ClassicEditor from '@ckeditor/ckeditor5-build-classic';

then receive errorwindow定义. 我尝试了很多选择,但无法解决这些问题。现在我要导入ClassicEditor仅适用于浏览器平台。但问题是

this.isBrowser = isPlatformBrowser(this.platformId);

isBowser值接收true|false后初始化组件构造函数。有人能告诉我如何像下面这样有条件地导入文件吗?

if(isBowser){
import * as ClassicEditor from '@ckeditor/ckeditor5-build-classic';
}

if(isPlatformBrowser(this.platformId)){
import('@ckeditor/ckeditor5-build-classic').then(i => {
this.ClassicEditor = i.default;
};
}

最新更新