vue中是使用富文本编辑器vue-quill-edit
之前使用的富文本编辑器是uEditor,kindEditor,感觉不太方便
近期项目vue单页面,就使用这个编辑器组件吧!
一、安装 cnpm 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;
top: -10px;
}
.ql-snow .ql-color-picker .ql-picker-label svg, .ql-snow .ql-icon-picker .ql-picker-label svg{position: relative;top:-6px;}
}
</style>
四、引入使用:
<my-editor :contentDefault="contentDefault"></my-editor>
components:{
    myEditor:myEditorComponent
  },
vue中是使用富文本编辑器vue-quill-edit的更多相关文章
- vue+element-ui 使用富文本编辑器
		npm安装编辑器组件npm install vue-quill-editor –save 在components文件夹创建ue.vue组件,如下 ue.vue代码如下: <!-- 组件代码如下 ... 
- Django中使用富文本编辑器Uedit
		Uedit是百度一款非常好用的富文本编辑器 一.安装及基本配置 官方GitHub(有详细的安装使用教程):https://github.com/zhangfisher/DjangoUeditor 1. ... 
- Django实现的博客系统中使用富文本编辑器ckeditor
		操作系统为OS X 10.9.2,Django为1.6.5. 1.下载和安装 1.1 安装 ckeditor 下载地址 https://github.com/shaunsephton/django-c ... 
- Django后台管理admin或者adminx中使用富文本编辑器
		在admin或者adminx后台中使用富文本编辑器 一.建立模型:(安装django-tinymce==2.6.0) from django.db import models from tinymce ... 
- flask项目中使用富文本编辑器
		flask是一个用python编写的轻量级web框架,基于Werkzeug WSGI(WSGI: python的服务器网关接口)工具箱和Jinja2模板,因为它使用简单的核心,用extension增加 ... 
- django-应用中和amdin使用富文本编辑器kindeditor
		文章描述.新闻详情和产品介绍等,都需要大量的文字描述信息或图片.视频.文字的编辑等,这个时候我们就需要介绍第三方富文本编辑器. 今天介绍的是django中绑定和应用kindeditor编辑器: 效果如 ... 
- Django使用富文本编辑器
		1.下载kindeditor 网址:http://kindeditor.net/demo.php2.解压到项目中 地址:\static\js\kindeditor-4.1.103.删除没用的文件 例如 ... 
- 使用富文本编辑器Kindeditor
		今天在做需求的时候,遇到有一个字段,需要保存带有格式的内容,决定使用富文本框编辑器Kindeditor来实现,解决方法如下: 登录官网下载控件包: http://kindeditor.net/down ... 
- Vue 中使用UEditor富文本编辑器-亲测可用-vue-ueditor-wrap
		其中UEditor中也存在不少错误,再引用过程中. 但是UEditor相对还是比较好用的一个富文本编辑器. vue-ueditor-wrap说明 Vue + UEditor + v-model 双向绑 ... 
随机推荐
- Redis批量导入数据的方法
			有时候,我们需要给redis库中插入大量的数据,如做性能测试前的准备数据.遇到这种情况时,偶尔可能也会懵逼一下,这里就给大家介绍一个批量导入数据的方法. 先准备一个redis protocol的文件( ... 
- 2018 CCPC网络赛  几道数学题
			1002 Congruence equation 题目链接 : http://acm.hdu.edu.cn/showproblem.php?pid=6439 题解 : https://www.zyb ... 
- 字王大藏经体v0.1概念版
			字王大藏经体v0.1概念版 zw-dzj 字王大藏经体v0.1概念版,是字王<中华大字库>2018版升级过程当中,在Github搜索资源时的意外惊喜. 大藏经为佛教经典的总集,简称为藏经. ... 
- 媒体查询@media  屏幕适配
			@media(max-width: 1199px){.banner{height: 400px;}}1.6倍@media(min-width: 1200px) and (max-width: 1365 ... 
- An owner of this repository has limited the ability to open a pull request to users that are collaborators on this repository.
			git 无法发起:pull request,提示:An owner of this repository has limited the ability to open a pull request ... 
- 融云亮相GDG谷歌女性开发者大会 揭秘IMSDK网络优化策略
			4 月 20 日,冷雨阻碍不了天津GDG谷歌女性开发者大会的热烈召开,一众开发者.架构师和科技公司创业者云集一堂,就女性开发者的技术.职场.人生多方面话题展开深入探讨.活动由GDG (谷歌开发者社区) ... 
- jquery的on()用法实例
			首先,先看官方描述: 再来,用实例解释一下: 1.简单绑定单个事件: $("body").on("click",".edit_btn",fu ... 
- 标签EL和JSTL解读
			1. EL标签:出现代替输出:<%=%> EL输出格式(特点:只能输出,不带逻辑) ${key值} 查找顺序:page,request,session,application **在不加 ... 
- Powershell获取硬件信息
			1.获取系统的BIOS的信息: Get-WMIObject -Class Win32_BIOS 2.获取内存信息: Get-WMIObject -Class Win32_PhysicalMemory ... 
- Gatling实战(三)
			无论是性能测试还是自动化测试,有一个很重要的点就是变量(参数化),因为真实环境是很少同时产生并发很高而且所有参数都一模一样的请求的,就算有这样的接口,开发肯定用缓存来挡了,这种一般不会是瓶颈,真正瓶颈 ... 
