vue-quill-editor设置disabled
最近项目用到了vue-quill-editor,但是有场景要给富文本编辑器添加disabled效果,查看官网api后得到以下解决方案,直接上代码html:<template><divclass="my-editor-comp"><quill-editor:class="[disabl...
·
最近项目用到了vue-quill-editor,但是有场景要给富文本编辑器添加disabled效果,查看官网api后得到以下解决方案,直接上代码
html:
<template>
<div
class="my-editor-comp">
<quill-editor
:class="[disabled ? 'is-disabled' : '']"
v-model="content"
ref="myQuillEditor"
:options="options"
@focus="onFocus($event)"
@blur="onBlur($event)">
</quill-editor>
</div>
</template>
js:
<script>
// 添加富文本编辑器require配置
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 {
name: 'MyEditor',
components: {
quillEditor
},
data(){
return{
// 是否显示按钮
disabled: false,
// 富文本内容
content: "",
// 富文本配置
options: {
modules: {
toolbar: {
container: [
['bold','italic','underline','strike'],
[{'size':['small', false, 'large', 'huge']}],
[{ 'color' : [] }, { 'background' : [] }],
[{ 'font' : [] }],
[{ 'align' : [] }],
['link', 'image'],
],
}
},
placeholder: "请输入",
},
}
},
methods: {
/**
* @method 鼠标进入
*/
onMouseover(){
if(this.disabled){
this.$refs.myQuillEditor.quill.enable(false);
}
},
/**
* @method 鼠标离开
*/
onMouseleave(){
if(this.disabled){
this.$refs.myQuillEditor.quill.enable(true);
}
},
}
}
</script>
实现核心:
富文本的enable方法,官网解释如下
点击阅读全文
更多推荐
所有评论(0)