鍍金池/ 問答/HTML/ vue中ueditor的數(shù)據(jù)展示

vue中ueditor的數(shù)據(jù)展示

問題描述

一個新聞編輯頁面,數(shù)據(jù)得到了,不知道怎么展示到ueditor上面

相關(guān)代碼

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>
編輯相關(guān)代碼:
<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("/"); //備份當(dāng)前圖片路徑
            this.imgUrl = backupImgUrl[backupImgUrl.length - 1];
        }
        //編輯器里面的內(nèi)容bus.editNewsData.newsContent就是要展示的數(shù)據(jù)
        bus.editNewsData.newsContent = bus.editNewsData.defaultContent;
        //editor.setContent(bus.editNewsData.newsContent)
        console.log(bus.editNewsData.newsContent);
        this.backupData = bus.editNewsData;
        return bus.editNewsData;
    }
},

}

回答
編輯回答
懶洋洋

已解決!自己沒有看清楚

2018年2月11日 15:35