code init
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<!-- 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/static/ueditor/ueditor.config.js'
|
||||
import '@/../public/static/ueditor/ueditor.all.js'
|
||||
import '@/../public/static/ueditor/lang/zh-cn/zh-cn.js'
|
||||
export default {
|
||||
name: 'UEditor',
|
||||
data () {
|
||||
return {
|
||||
editor: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getUEContent: function () {
|
||||
return this.editor.getContent()
|
||||
},
|
||||
getContentTxt: function () {
|
||||
return this.editor.getContentTxt()
|
||||
},
|
||||
setContent (content) {
|
||||
// return this.editor.setContent(content)
|
||||
this.editor.ready(() => {
|
||||
this.editor.setContent(content);
|
||||
})
|
||||
},
|
||||
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>
|
||||
Reference in New Issue
Block a user