update quill editor
This commit is contained in:
@@ -10,7 +10,8 @@ export default {
|
||||
ReadOnlyMode: false,
|
||||
Placeholder: '在这里输入描述信息...',
|
||||
ScrollingContainer: null,
|
||||
editor: null
|
||||
editor: null,
|
||||
content: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -34,11 +35,15 @@ export default {
|
||||
// 只在 mode 不为 create 的时候,才加载数据
|
||||
if (val && this.mode !== 'create') {
|
||||
// this.mode 会比 modelValue 先获得值
|
||||
this.editor && this.editor.setContents(JSON.parse(val), "user")
|
||||
this.content = JSON.parse(val)
|
||||
this.editor && this.editor.setContents(this.content, "user")
|
||||
} else if (val === null || val === undefined) {
|
||||
// 当 modelValue 传入空时,清空内容
|
||||
this.editor && this.editor.setContents('\n', "user")
|
||||
}
|
||||
},
|
||||
content(val) {
|
||||
this.$emit('update:modelValue', { subject: 'richInput', payload: { data: val } })
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@@ -71,7 +76,8 @@ export default {
|
||||
})
|
||||
|
||||
this.editor.on('text-change', (delta, oldDelta, source) => {
|
||||
this.$emit('update:modelValue', { subject: 'richInput', payload: { data: this.editor.getContents() } })
|
||||
this.content = this.editor.getContents()
|
||||
// this.$emit('update:modelValue', { subject: 'richInput', payload: { data: this.editor.getContents() } })
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
||||
Reference in New Issue
Block a user