problem description
A news editor page, the data has been obtained, and I don"t know how to display it on ueditor
related codes
ueditor component:
< template >
<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 >
Edit the relevant code:
< Ueditor @ ready= "editorReady" ref= "myTextEditor" v Mustok 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;
}
},
}