vue-quill-editor 插入html
时间: 2023-08-28 07:08:21 浏览: 34
要在 vue-quill-editor 中插入 HTML,可以使用以下步骤:
1. 首先,在 Vue 项目中安装 vue-quill-editor:
```shell
npm install vue-quill-editor
```
2. 在需要使用 vue-quill-editor 的组件中引入它:
```javascript
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
export default {
components: {
VueQuillEditor
},
// ...
}
```
3. 在模板中使用 vue-quill-editor,并绑定一个数据属性来保存编辑器的内容:
```html
<template>
<div>
<vue-quill-editor v-model="editorContent"></vue-quill-editor>
</div>
</template>
```
4. 然后,在你想要插入 HTML 的时候,可以使用 `v-html` 指令来渲染 HTML 内容:
```html
<template>
<div>
<vue-quill-editor v-model="editorContent"></vue-quill-editor>
<div v-html="editorContent"></div>
</div>
</template>
```
这样,你就可以通过编辑器输入 HTML 内容,并在另一个元素中渲染出来了。请注意,`v-html` 指令会直接将内容作为 HTML 解析,因此请确保输入的内容是可信任的,以防止 XSS 攻击。
相关推荐










