问题
前端的ueditor获取从后台传过来的值使用setContent()方法,但若是在实例化了Ueditor之后直接使用setContent()方法会出现报错:
解决
等ueditor创建完再调用它的方法,可以在使用的地方加一个监听器,代码如下:
var ue = UE.getEditor('container');
ue.addListener("ready", function () {
// editor准备好之后才可以使用
ue.setContent("要传到ueditor中的数据");
});
JS中获取ueditor中的内容使用方法getContent(),如下:
var content= ue.getContent();