vue富文本编辑器组件vue-quill-edit使用教程
网络编程 2021-07-04 16:46www.168986.cn编程入门
这篇文章主要为大家详细介绍了vue富文本编辑器组件vue-quill-edit的使用教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
之前使用的富文本编辑器是uEditor,kindEditor,感觉不太方便。
近期项目vue单页面,就使用vue-quill-edit这个编辑器组件吧!
一、安装 pm install vue-quill-editor
二、引入
在main.js引入并注册
import VueQuillEditor from 'vue-quill-editor' // require styles 引入样式 import 'quill/dist/quill.core.css' import 'quill/dist/quill.snow.css' import 'quill/dist/quill.bubble.css' Vue.use(VueQuillEditor)
三、封装组件
<template> <div class="quill_box"> <quill-editor v-model="content" ref="myQuillEditor" :options="editorOption" @blur="onEditorBlur($event)" @focus="onEditorFocus($event)" @change="onEditorChange($event)"> </quill-editor> </div> </template> <script> import Bus from "../../assets/utils/eventBus"; export default { data() { return { content:'', editorOption: { placeholder: "请编辑内容", modules: { toolbar: [ ["bold", "italic", "underline", "strike"], ["blockquote", "code-block"], [{ list: "ordered" }, { list: "bullet" }], [{ script: "sub" }, { script: "super" }], [{ indent: "-1" }, { indent: "+1" }], [{ size: ["small", false, "large", "huge"] }], [{ font: [] }], [{ color: [] }, { background: [] }], [{ align: [] }], [ "image"] ] } } }; }, props:[ 'contentDefault' ], watch:{ contentDefault:function(){ this.content = this.contentDefault; } }, mounted:function(){ this.content = this.contentDefault; }, methods: { onEditorBlur() { //失去焦点事件 // console.log('失去焦点'); }, onEditorFocus() { //获得焦点事件 // console.log('获得焦点事件'); }, onEditorChange() { //内容改变事件 // console.log('内容改变事件'); Bus.$emit('getEditorCode',this.content) } } }; </script> <style lang="less"> .quill_box{ .ql-toolbar.ql-snow{border-color:#dcdfe6;} .ql-container{height:200px !important;border-color:#dcdfe6;} .ql-snow .ql-picker-label::before { position: relative; : -10px; } .ql-snow .ql-color-picker .ql-picker-label svg, .ql-snow .ql-icon-picker .ql-picker-label svg{position: relative;:-6px;} } </style>
四、引入使用
<my-editor :contentDefault="contentDefault"></my-editor> ponents:{ myEditor:myEditorComponent },
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。
编程语言
- 宿迁百度关键词排名指南:实现精准营销的关键
- 四川SEO优化怎么做网络推广
- 立昂技术备案老域名收购:如何为您的业务赋能
- 安徽百度关键词seo贵不贵,一般需要多少钱
- 吉林百度快照排名怎么做电话营销
- 多伦新手做SEO怎么做
- 甘肃优化关键词排名推广怎么做论坛营销
- 沙雅SEO网站推广:提升您的在线可见性
- 四川SEO优化如何提升销售额和销售量
- 聂荣网站排名优化:提升网站可见性的全方位指
- 涞水SEO:提升地方企业在线可见性的策略
- 辽宁百度seo排名怎样做网站排名
- 临湘哪有关键词排名优化:提升网站可见度的关
- 黑龙江百度网站优化有没有优惠
- 凉城优化关键词排名推广:提升您的网络可见性
- 萝北整站优化:提升您网站流量和排名的全面指