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
66
67
68
69
70
71
72
73
74
75
76
77
78
| <template>
| <div>
| <script id="editor" type="text/plain"></script>
| <Upload v-if="isupload" :config="{total:9}" :isupload="isupload" @returnImgs="returnImgsFunc">上传图片</Upload>
| </div>
| </template>
| <script>
| import Upload from '@/components/file/Upload';
| export default {
| components:{Upload},
| name: 'ue',
| data() {
| return {
| editor: null,
| isupload:false,
| hasCallback: false,
| callback: null,
| this_config:{
| //不需要工具栏漂浮
| autoFloatEnabled:false
| }
| }
| },
| props: {
| text: String,
| config: Object
| },
| created() {
| /*富文本框的默认选择图片方式,改成自定义的选择方式*/
| window.openUpload = this.openUpload;
| },
| watch:{
|
| },
| mounted() {
|
| Object.assign(this.this_config,this.config);
| this.editor = window.UE.getEditor('editor', this.this_config);
| this.editor.addListener('ready', (e) => {
| this.editor.setContent(this.text);
| });
|
| /*监听富文本内容变化,有变化传给调用组件的页面*/
| this.editor.addListener('contentChange', (e) => {
| this.$emit('contentChange',this.editor.getContent());
| });
| },
| methods: {
|
| /*获取富文本框内容*/
| getUEContent() {
| return this.editor.getContent()
| },
|
| /*打开选择图片*/
| openUpload: function(callback) {
| this.isupload = true;
| if (callback) {
| this.hasCallback = true;
| this.callback = callback;
| }
| },
|
| /*获取图片*/
| returnImgsFunc(e) {
| if (e != null) {
| this.hasCallback && this.callback(e);
| }
| this.isupload = false;
| },
| },
|
| /*销毁*/
| destroyed() {
| this.editor.destroy()
| }
| }
| </script>
|
|