Spring框架整合百度编辑器遇到的问题

ueditor文档:http://fex.baidu.com/ueditor/

1:准备工作,下载demo 选jsp的

2http://fex.baidu.com/ueditor/#server-jsp

3:框架拦截后缀为.jsp的文件请求,所以需要放过数据,免得取不到数据,改web.xml文件放过权限

4:页面中初始化遇到的问题:

  • 直接初始化渲染不出来,或者第一次正常,二次加载不正常,需要先删在建才能正常渲染
  • UE.getEditor('container3').render('container3')  这种html切换有异常,暂不做考虑了  参考文章:https://blog.csdn.net/zrk1000/article/details/46865093#commentBox
  • 还是用UE.getEditor这种可以自定义栏目图标,先删除在创建就没问题了
UE.delEditor('container2');//可能是缓存问题导致的,因此先删除缓存中已有的富文本
        var ue = UE.getEditor('container2', {
            toolbars: [
                       ['fullscreen', 'source', 'undo', 'redo', 'bold']
                   ],
                   autoHeightEnabled: true,
                   autoFloatEnabled: true
               }
        );//再重新渲染

//不自定义标签
UE.delEditor('container3'); UE.getEditor('container3');

但删除缓存中的富文本这个在IE下不兼容,参考文章https://blog.csdn.net/wslpeter1987/article/details/76530075

那解决起来就比较简单:

正常渲染某个container为富文本的做法是:UE.getEditor("container");但这里我们不用这个方法,我们直接自己模仿ueditor.all.js中getEditor()方法来实现container的渲染:

var editor = new UE.ui.Editor(opt);

editor.render(id);

其中opt,id就是UE.getEditor(id,[opt])方法的签名,opt是可选项,而且可以看出,如果一个页面渲染多个container;editor只需实例化一次就ok

var editor = new UE.ui.Editor(opt);

editor.render(id1);

editor.render(id2);

editor.render(id3);

 

还有另外一种删除,暂没试

        if(typeof(UE.getEditor("container3")) !='undefined'){
             UE.getEditor("container3").destroy();
        }
        if(typeof(UE.getEditor("container4")) !='undefined'){
             UE.getEditor("container4").destroy();
        }
        UE.getEditor('container3');
        UE.getEditor('container4');

 

 

 

 

UEditor 第一次加载正常,第二次无法正常加载问题

posted @ 2019-03-28 13:18  李晓梦  阅读(171)  评论(0编辑  收藏  举报