bug修改

This commit is contained in:
caoyang
2022-03-15 18:17:30 +08:00
parent b443cdd4c3
commit 2a4577f606
4 changed files with 230 additions and 13 deletions
+103
View File
@@ -0,0 +1,103 @@
<!-- UEditor -->
<template>
<div>
<script id="editor" type="text/plain" ></script>
</div>
</template>
<script>
/* eslint-disable */
// import 'ueditor/example/public/ueditor/ueditor.config'
// import 'ueditor/example/public/ueditor/ueditor.all'
// import 'ueditor/example/public/ueditor/lang/zh-cn/zh-cn'
// import '@/../public/ueditor/ueditor.config.js'
// import '@/../public/ueditor/ueditor.all.js'
// import '@/../public/ueditor/lang/zh-cn/zh-cn.js'
export default {
name: 'UEditor',
data () {
return {
editor: null
}
},
methods: {
getUEContent: function () {
// return this.editor.ready(()=>{
// this.editor.getContent()
// })
return this.editor.getContent()
},
getContentTxt: function () {
return this.editor.getContentTxt()
},
setContent (content) {
return this.editor.ready(()=>{
this.editor.setContent(content,true)
})
},
// 清空内容
execCommand (content) {
return this.editor.execCommand('cleardoc')
},
getContentLength () {
return this.editor.getContentLength()
}
},
props: {
id: {
type: String
},
config: {
type: Object
},
fontfamily: {
type: String,
default: ''
},
fontsize: {
type: String,
default: ''
},
bold: {
type: Boolean,
default: false
},
content:{
type: String,
default: ''
}
},
watch: {
},
mounted () {
// 初始化UE
this.editor = UE.delEditor('editor')
this.editor = UE.getEditor('editor', this.config)
let _this = this
UE.getEditor('editor').addListener('blur',function(editor){
_this.$emit('editor-onChange', _this.getUEContent())
});
UE.getEditor('editor').ready(function() {
if (_this.fontfamily !== '') {
UE.getEditor('editor').execCommand( 'fontfamily',_this.fontfamily)
}
if (_this.content !== '') {
UE.getEditor('editor').setContent(_this.content)
}
if (_this.fontsize !== '') {
UE.getEditor('editor').execCommand( 'fontsize', _this.fontsize )
}
if (_this.bold) {
UE.getEditor('editor').execCommand('bold')
}
});
},
destoryed () {
this.editor.destory()
}
}
</script>