UEditor编辑器第一次赋值失败的解决方法

网上查了很多方式都不是很好用,最后想到了这样的处理方式

首先在js中定义一个全局变量

var ue = null;

然后在初始化显示编辑器的时候js这样写 

if (ue == null) {
ue = new baidu.editor.ui.Editor();
ue.render('email_template');
}
ue.setContent("11111");

这样就可以第一次的时候正常显示编辑器的值

--初始化赋值 避免js报错

var ue = UE.getEditor('txtContent', {
toolbars: [
['bold', 'italic', 'underline', 'fontborder', 'justifyleft', 'justifycenter',
'justifyright', 'justifyjustify']
]
});
ue.addListener("ready", function () {
// editor准备好之后才可以使用
ue.setContent('abc');
});

原文地址:https://www.cnblogs.com/hgmyz/p/7465812.html