vue中ueditor的数据展示

新手上路,请多包涵

问题描述

一个新闻编辑页面,数据得到了,不知道怎么展示到ueditor上面

相关代码

ueditor组件:
<template>
<div>

<script :id="randomId"  type="text/plain"></script>

</div>
</template>
<script>
import '../../../static/Ueditor/ueditor.config.js'
import '../../../static/Ueditor/ueditor.all.js'
import '../../../static/Ueditor/lang/zh-cn/zh-cn.js'
export default {

props: {
  ueditorConfig:{}
},
data () {
  return {
    randomId: 'editor_' + (Math.random() * 100000000000000000),
    instance: null,
  };
},
mounted () {
  this.initEditor()
},

beforeDestroy () {
  if (this.instance !== null && this.instance.destroy) {
    this.instance.destroy();
  }
},
methods: {
  initEditor () {
      this.$nextTick(() => {
        this.instance = UE.getEditor(this.randomId, this.ueditorConfig);
        this.instance.addListener('ready', () => {
          this.$emit('ready', this.instance);
          //this.instance.execCommand('inserthtml', '123')
        });
      });
  },
  getUEContent() { 
    return this.editor.getContent()
  },
}

};
</script>
编辑相关代码:
<Ueditor @ready="editorReady" ref="myTextEditor" v-model="editNewsData.newsContent" :options="editorOption" id='ueditor'></Ueditor>

import Ueditor from "../module/Ueditor";

export default {
computed: {

    editNewsData() {
        if (bus.editNewsData.id === undefined) {
            this.$router.push("/newslist");
        } else if (bus.editNewsData.thumbnail !== null) {
            let backupImgUrl = bus.editNewsData.thumbnail.split("/"); //备份当前图片路径
            this.imgUrl = backupImgUrl[backupImgUrl.length - 1];
        }
        //编辑器里面的内容bus.editNewsData.newsContent就是要展示的数据
        bus.editNewsData.newsContent = bus.editNewsData.defaultContent;
        //editor.setContent(bus.editNewsData.newsContent)
        console.log(bus.editNewsData.newsContent);
        this.backupData = bus.editNewsData;
        return bus.editNewsData;
    }
},

}

阅读 3.5k
1 个回答
✓ 已被采纳新手上路,请多包涵

已解决!自己没有看清楚

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题