問題描述

原因分析
- Ueditor重復加載時,會存在緩存問題
- Ueditor采用異步加載方式,所以數據獲取和賦值要寫在Ueditor異步回調里
解決方案
UE.delEditor('txtContent'); //先刪除之前Ueditor實例對象
var self = this;
var editor = UE.getEditor('txtContent', {
toolbars: toolbar,
initialFrameHeight: 600,//設置編輯器高度
scaleEnabled: false//設置不自動調整高度
});
editor.addListener("ready", function () {
self.editor = editor;
//獲取數據
$.ajax({
type: "GET",
url: "http://127.0.0.1/admin/news?id=1",
success: function(result) {
console.log(result);
//self.editor.setContent(result.FDetail);
}
});
});
處理結果
