v2.3 版本发布,详情查看版本说明

This commit is contained in:
dqjdda
2019-11-01 19:35:16 +08:00
parent 934a419cdb
commit 637e8357a7
5 changed files with 18 additions and 26 deletions

View File

@@ -1,36 +1,23 @@
<template>
<div>
<div ref="editor" style="text-align:left;margin: 5px">
<div v-html="editorContent"/>
</div>
<div ref="editor" class="text"/>
<div style="margin: 12px 5px;font-size: 16px;font-weight: bold;color: #696969">HTML渲染如下</div>
<div class="editor-content" v-html="editorContent"/>
</div>
</template>
<script>
import { debounce } from 'lodash'
import { mapGetters } from 'vuex'
import E from 'wangeditor'
import { getToken } from '@/utils/auth'
export default {
name: 'Editor',
model: {
prop: 'value',
event: 'editorChange'
},
props: {
value: {
type: String,
default: () => ''
}
},
data() {
return {
headers: {
'Authorization': 'Bearer ' + getToken()
},
editorContent: this.value ||
editorContent:
`<h3 style="text-align: center;">欢迎使用 wangEditor 富文本编辑器!</h3>
<ul>
<li>富文本中图片上传使用的是sm.ms图床支持上传到七牛云<a style="color: #42b983" target="_blank" href="https://sm.ms/">sm.ms</a></li>
@@ -51,11 +38,12 @@ export default {
// 自定义文件名,不可修改,修改后会上传失败
editor.customConfig.uploadFileName = 'file'
editor.customConfig.uploadImgServer = this.imagesUploadApi // 上传图片到服务器
editor.customConfig.onblur = debounce(html => {
this.$emit('editorChange', html)
editor.customConfig.onchange = (html) => {
this.editorContent = html
}, 1000)
}
editor.create()
// 初始化数据
editor.txt.html(this.editorContent)
}
}
</script>
@@ -64,4 +52,8 @@ export default {
.editor-content{
padding-left: 5px;
}
.text {
text-align:left;
margin: 5px
}
</style>