美文网首页
富文本编辑器加载问题

富文本编辑器加载问题

作者: 只诉温暖不言殇_cc03 | 来源:发表于2020-06-02 09:13 被阅读0次

    使用ueditor富文本编辑器的getcontent()方法时,报错找不到这个编辑器对象

    html:

    <script type="text/plain" name="details" id="details" style="width:1000px;height:240px;line-height: 20px;margin-bottom:20px">{{detailsHtml}}</script>

    js:

    var toolbars=[['simpleupload','inserttable', 'insertorderedlist','insertunorderedlist','justifyleft', 'justifyright']];//设置编辑器的工具栏

    _this.paramUe = UE.getEditor('paramScale',{toolbars});//获取编辑器对象

    如果此时直接调用编辑器的方法

    _this.paramUe.getContent(),_this.paramUe.setContent()方法会报错,找不到这个对象或者paramue未定义

    原因是此时编辑器还未加载完成

    纠正: 

    _this.paramUe.ready(function() {

           //设置编辑器的内容

          mark = _this.paramUe.getContent()

              if(!mark) {

                      return false

               }

    });

    此外,还需注意的是如果当前富文本内容包含图片,需要将改富文本内容中的图片上传到后台,然后获取后台返回的一个图片地址才可以提交,因为当前上传的是本地图片,如果直接提交给后台无法解析图片地址,因此要中转一下

    相关文章

      网友评论

          本文标题:富文本编辑器加载问题

          本文链接:https://www.haomeiwen.com/subject/ihxfuctx.html