admin管理员组文章数量:1640592
最近项目用到了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方法,官网解释如下
版权声明:本文标题:vue-quill-editor设置disabled 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729320642a1195840.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论