1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<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>