原来的项目使用<script> cdn 来加载 wangEditor.js ,体验相当不好,会导致页面白屏好长一段时间
使用 defer 的话,就不能在正确的时间引用这个 文件,就想到了使用 异步调用
componentDidMount() {
const e = import('./wangEditor.min.js');
e.then(({ default: wangEditor}) => {
const editor = new wangEditor('#div3');
editor.create();
})
}
在 ant-design-pro 之中,已经封装了 import() 的babel 配置,可以直接使用