<template> <div> <VueUeditorWrap :config="editorConfig" v-model="content" :destroy="true" @ready="ready"/> </div> </template> <script> import VueUeditorWrap from 'vue-ueditor-wrap' export default { components: { VueUeditorWrap }, name: "baiduEditor", created() { }, watch: { content(content) { this.$emit('input', content); } }, beforeDestroy() { }, data() { return { editorConfig: { autoHeightEnabled: false, //编译器不自动被内容撑高 initialFrameHeight: 400, //初始容器高度 initialFrameWith: "90%", serverUrl: "", //上传文件地址 UEDITOR_HOME_URL: "/ueditor/", //UEditor资源文件的存放路径 }, content: "", UEditor: null } }, props: { config: { type: Object } }, methods: { ready(editor) { //编辑器实例 this.UEditor = editor; this.$emit('baiduEditorReady', true) }, //获取内容 getContent() { return this.content; }, //设置内容 setContent(content, isEnabled = true) { if (isEnabled) { this.UEditor.setDisabled('fullscreen'); } else { this.UEditor.setEnabled(); } return this.UEditor.setContent(content); } }, } </script> <style scoped> </style>