vue + UEditor 第一次富文本加载不出来 但刷新后会加载出来

vue + UEditor 开发第一次什么反应都没有 刷新后才会加载出来

UEditor 组件

<template>
    <script :id=id type="text/plain"></script>
</template>
<script>
  import * as _ from '../util/tool';
  export default {
    name: 'UE',
    data () {
      return {
        editor: null,
        flag:true,
      }
    },
    props: {
      defaultMsg: {
        type: String
      },
      config: {
        type: Object
      },
      id: {
        type: String
      }
    },
    activated() {
      this.init();
    },
    methods: {
      init(){
        if(!UE.Editor.prototype._bkGetActionUrl){
          UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;//修改图片上传地址
          UE.Editor.prototype.getActionUrl = function(action) {
              if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadfile' || action =='uploadvideo') {
                  return '/ueditor/upload.html';
              } else {
                  return this._bkGetActionUrl.call(this, action);
              }
            };
        };
        let _this = this;
        this.editor = UE.getEditor(_this.id, _this.config); // 初始化UE
      },
      getUEContent() { // 获取内容
        return this.editor.getContent()
      },
      setUEContent(val) { // 设置内容
        return this.editor.setContent(val);
      },
      getUEContentText(){ // 获取纯文本内容
        return this.editor.getContentTxt();
      },
      destroyed(){
        return this.editor.destroy();
      }
    },
    deactivated() {
        //销毁编辑器实例,使用textarea代替
        //this.editor.destroy()
        //重置编辑器,可用来做多个tab使用同一个编辑器实例
        //如果要使用同一个实例,请注释destroy()方法
        this.editor.reset()
    }
  }
</script>

组件中调用

~ ~ ~
data(){
    return {
        Ueditor: 'ue1',
        config: {
                  initialFrameWidth: null,
                  initialFrameHeight: 350
                },
    }
}
~ ~ ~


 <UE ref="bdeditor" :id="Ueditor" :config=config></UE>

但是我重新登录后会什么都不显示

clipboard.png

刷新后会显示出来

clipboard.png

会不会和缓存有关系

各位大佬帮我看一下

阅读 9k
4 个回答

activated keep-alive组件激活时调用 免不了是这个缘故

我也遇到这个问题 你解决了吗

mounted() {
    this.editor = UE.getEditor('editor', this.config) // 初始化UE
},
destroyed() {//销毁后,第一次和切换路由后都能加载出来
  this.editor.destroy();
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题