發現 editor 組件,設置v-model 後, 修改 v-model 數據, editor組件沒有自動渲染,須要手動設置渲染javascript
this.$refs.editor.setHtml(this.model.description)java
<template>
<div>
<editor v-model="model.description" ref="editor" :cache="false"/>
</div>
</template>
<script>
import Editor from '_c/editor'
export default {
components: { Editor },
data () {
return {
model: { description: '' }
}
},
methods: {
Bind () {
// 模擬ajax讀取數據綁定
this.model.description = 'hello word'
this.$refs.editor.setHtml(this.model.description) // 加上這句才能夠
}
},
mounted () {
this.Bind()
}
}
</script>