先看效果图:
下载Vue-Quill-Editor
npm install vue-quill-editor --save
下载quill(Vue-Quill-Editor需要依赖)
npm install quill --save
代码
<template> <div class="edit_container"> <quill-editor v-model="form.goods_desc" ref="myQuillEditor" :options="editorOption" @blur="onEditorBlur($event)" @focus="onEditorFocus($event)" @change="onEditorChange($event)"> </quill-editor> </div> </template> <script> import { quillEditor } 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: { quillEditor }, data() { return { form:{ goods_desc: '' }, editorOption: {} } }, methods: { onEditorReady(editor) { // 准备编辑器 }, onEditorBlur(){ console.log(this.form) }, // 失去焦点事件 onEditorFocus(){}, // 获得焦点事件 onEditorChange(){}, // 内容改变事件 }, computed: { editor() { return this.$refs.myQuillEditor.quill; }, } } </script>
OK,搞定,简洁的富文本编辑器就展现在你眼前了。当然还可以通过配置editorOption选择自己需要的功能,让编辑器更简练些,这里就不赘述了!
原文地址:https://blog.csdn.net/senmage/article/details/82388728