我正在尝试使用webpack按需加载CKEditor。我已经尝试将它构建到入口块中并且它工作得很好。当我试图将它分成另一个块时,我得到了一个半载的。
我的代码(在coffeescript中):
componentDidMount: ->
require.ensure ["../asset/js/ckeditor.js"], (require) =>
CKEditor = require "exports?CKEDITOR!../asset/js/ckeditor.js"
console.log CKEditor
editor = ReactDOM.findDOMNode @refs.Editor
@ckeditor = CKEditor.replace editor
@ckeditor.setData @props.ele.html()
和我得到的CKEditor(由console.log行打印)
Object {timestamp: "", version: "%VERSION%", revision: "%REV%", rnd: 352, _: Object…}
_: Object
_autoLoad: "ckeditor"
basePath: "http://192.168.245.128:3000/ckeditor/"
domReady: (b)
getUrl: (a)
revision: "%REV%"
rnd: 352
skinName: "moono"
status: "unloaded"
timestamp: ""
version: "%VERSION%"
__proto__: Object
当然,我也有例外Uncaught TypeError: CKEditor.replace is not a function
我用谷歌搜索了一段时间CKEditor.on "loaded"
是我发现的唯一的东西,但显然它不起作用,因为on
也未定义。