修改富文本编辑器绑定值方式,使用:value,手动修改内容时调用组件的setHtml方法
This commit is contained in:
parent
260c0e3f7b
commit
42fd083f31
|
|
@ -45,6 +45,11 @@ export default {
|
|||
return `editor${this._uid}`
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setHtml (val) {
|
||||
this.editor.txt.html(val)
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.editor = new Editor(`#${this.editorId}`)
|
||||
this.editor.customConfig.onchange = (html) => {
|
||||
|
|
@ -57,7 +62,7 @@ export default {
|
|||
// create这个方法一定要在所有配置项之后调用
|
||||
this.editor.create()
|
||||
// 如果本地有存储加载本地存储内容
|
||||
let html = localStorage.editorCache
|
||||
let html = this.value || localStorage.editorCache
|
||||
if (html) this.editor.txt.html(html)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,7 +293,8 @@ export default [
|
|||
name: 'params',
|
||||
meta: {
|
||||
icon: 'md-flower',
|
||||
title: '动态路由'
|
||||
title: '动态路由',
|
||||
notCache: true
|
||||
},
|
||||
component: () => import('@/view/argu-page/params.vue')
|
||||
},
|
||||
|
|
@ -302,7 +303,8 @@ export default [
|
|||
name: 'query',
|
||||
meta: {
|
||||
icon: 'md-flower',
|
||||
title: '带参路由'
|
||||
title: '带参路由',
|
||||
notCache: true
|
||||
},
|
||||
component: () => import('@/view/argu-page/query.vue')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<div>
|
||||
<editor v-model="content" @on-change="handleChange"/>
|
||||
<editor ref="editor" :value="content" @on-change="handleChange"/>
|
||||
<button @click="changeContent">修改编辑器内容</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -13,12 +14,15 @@ export default {
|
|||
},
|
||||
data () {
|
||||
return {
|
||||
content: ''
|
||||
content: '12312323'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleChange (html, text) {
|
||||
console.log(html, text)
|
||||
},
|
||||
changeContent () {
|
||||
this.$refs.editor.setHtml('<p>powered by wangeditor</p>')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue