vue quill editor官网怎样给ol加class

在 SegmentFault,解决技术问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
一线的工程师、著名开源项目的作者们,都在这里:
获取验证码
已有账号?
问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
vue-quill-editor图片上传后如何返回一个路径?默认是返回一个一个base64,如何进行改造呢,改造加上一个图片上传地址,然后这个地址返回图片存储路径。
同步到新浪微博
分享到微博?
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:在 SegmentFault,解决技术问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
一线的工程师、著名开源项目的作者们,都在这里:
获取验证码
已有账号?
问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
我再使用富文本编辑器vue-quill-editor的时候,使用图片上传发现它是把图片转为base后插在文本中,然后我直接是提交了,但发现太大了在查询的时候很慢。
所以想问下vue-quill-editor怎么把上传图片怎么改为后台上传然后返回个图片的url再插入。看了整天英文文档,找来找去找不到。恳求解答下。
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
我也正在寻找完美的解决方案,目前的办法:
vue-quill-editor作者surmon也作了一些扩展说明
官方的issues里很多这个问题的讨论,比如
按照下面jackmu95的做法是可以自定义imageHandler的,不过可能需要自己修改
分享到微博?
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:vue-quill-editor默认插入图片是直接将图片转为base64再放入内容中,如果图片比较大的话,富文本的内容就会很大。
插入视频是直接弹框输入URL地址,某些需求下我们需要让用户去本地选择自己的视频,我们可以通过vue-quill-editor内部的某些方法进行更改
该方法使用了&element-ui 和 文件上传七牛
一、npm 安装&vue-quill-editor
二、在main.js中引入
VueQuillEditor from 'vue-quill-editor'
Vue.use(VueQuillEditor)
HTML部分:为编辑器绑定各个API事件,定义一个隐藏的input框,用于点击图片或者视频图标上传文件
&template&
&!-- quill-editor插件标签 分别绑定各个事件--&
&quill-editor v-model="content" ref="myQuillEditor" :options="editorOption" @blur="onEditorBlur($event)" @focus="onEditorFocus($event)"
@change="onEditorChange($event)"&
&/quill-editor&
&div class="limit"&当前已输入 &span&{{nowLength}}&/span& 个字符,您还可以输入 &span&{{SurplusLength}}&/span& 个字符。&/div&
&!-- 文件上传input 将它隐藏--&
&el-upload class="upload-demo" :action="qnLocation" :before-upload='beforeUpload' :data="uploadData" :on-success='upScuccess'
ref="upload" style="display:none"&
&el-button size="small" type="primary" id="imgInput" v-loading.fullscreen.lock="fullscreenLoading" element-loading-text="插入中,请稍候"&点击上传&/el-button&
&/el-upload&
&/el-table&
&/template&
.quill-editor {
height: 745px;
.ql-container {
height: 680px;
height: 30px;
border: 1px solid #ccc;
line-height: 30px;
text-align: right;
color: #ee2a7b;
.ql-snow .ql-editor img {
max-width: 480px;
.ql-editor .ql-video {
max-width: 480px;
import Vue from 'util/vueExt'
import { Component } from 'vue-property-decorator'
import * as Template from './editor.vue'
import * as Quill from 'quill'
// 引入编辑器
const STATICDOMAIN = '///'
const STATVIDEO = '///'
@Component({
mixins: [Template]
export default class Editor extends Vue {
content = ''
// 文章内容
editorOption = {}
// 编辑器选项
addRange: any = new Array()
uploadData = {}
photoUrl = ''
// 上传图片地址
uploadType = ''
// 上传的文件类型(图片、视频)
fullscreenLoading = false
myQuillEditor: any,
imgInput: any
get nowLength() {
return this.content.length
get SurplusLength() {
// 计算属性 获得当前输入字符长度
let num = 10000 - Number(this.content.length)
if (num & 0) {
return num
// 上传七牛的actiond地址
get qnLocation() {
if (location.protocol === 'http:') {
return 'http://up-'
return 'https://up-z0.qbox.me'
// 图片上传前获得数据token数据
qnUpload(file) {
this.fullscreenLoading = true
const suffix = file.name.split('.')
const ext = suffix.splice(suffix.length - 1, 1)[0]
console.log(this.uploadType)
if (this.uploadType === 'image') {
// 如果是点击插入图片
return this.api.getQNToken().then(res =& {
this.uploadData = {
key: `image/${suffix.join('.')}_${new Date().getTime()}.${ext}`,
token: res
} else if (this.uploadType === 'video') {
// 如果是点击插入视频
return this.api.getVideoQNToken().then(res =& {
this.uploadData = {
key: `video/${suffix.join('.')}_${new Date().getTime()}.${ext}`,
token: res
// 图片上传之前调取的函数
beforeUpload(file) {
return this.qnUpload(file)
// 图片上传成功回调
插入到编辑器中
upScuccess(e, file, fileList) {
this.fullscreenLoading = false
let vm = this
let url = ''
if (this.uploadType === 'image') {
// 获得文件上传后的URL地址
url = STATICDOMAIN + e.key
} else if (this.uploadType === 'video') {
url = STATVIDEO + e.key
if (url != null && url.length & 0) {
// 将文件上传后的URL地址插入到编辑器文本中
let value = url
vm.addRange = vm.$refs.myQuillEditor.quill.getSelection()
value = value.indexOf('http') !== -1 ? value : 'http:' + value
vm.$refs.myQuillEditor.quill.insertEmbed(vm.addRange !== null ? vm.addRange.index : 0, vm.uploadType, value, Quill.sources.USER)
// 调用编辑器的 insertEmbed 方法,插入URL
(&any&this).$message.error(`${vm.uploadType}插入失败`)
this.$refs['upload'].clearFiles()
// 插入成功后清除input的内容
// 点击图片ICON触发事件
imgHandler(state) {
this.addRange = this.$refs.myQuillEditor.quill.getSelection()
if (state) {
let fileInput = document.getElementById('imgInput')
fileInput.click() // 加一个触发事件
this.uploadType = 'image'
// 点击视频ICON触发事件
videoHandler(state) {
this.addRange = this.$refs.myQuillEditor.quill.getSelection()
if (state) {
let fileInput = document.getElementById('imgInput')
fileInput.click() // 加一个触发事件
this.uploadType = 'video'
// 编辑器光标离开 将编辑器内容发射给父组件
onEditorBlur(editor) {
this.$emit('getValue', this.content)
// 编辑器获得光标
onEditorFocus(editor) {
editor.enable(true)
// 实现达到上限字符可删除
// 编辑器文本发生变化
onEditorChange({ editor, html, text }) {
let textLength = text.length
if (textLength & 10000) {
(&any&this).$message.error('最多输入10000个字符')
editor.enable(false)
this.$emit('getValue', this.content)
// 清除编辑器内容
callMethod() {
this.content = ''
// 页面加载后执行 为编辑器的图片图标和视频图标绑定点击事件
mounted() {
// 为图片ICON绑定事件
getModule 为编辑器的内部属性
this.$refs.myQuillEditor.quill.getModule('toolbar').addHandler('image', this.imgHandler)
this.$refs.myQuillEditor.quill.getModule('toolbar').addHandler('video', this.videoHandler)
// 为视频ICON绑定事件
&相关参考链接:
阅读(...) 评论()拒绝访问 | www. | 百度云加速
请打开cookies.
此网站 (www.) 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(3c24d8cce70643c5-ua98).
重新安装浏览器,或使用别的浏览器}

我要回帖

更多关于 vuequilleditor 中文 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信