vue-quill-editor富文本編輯器簡單使用方法
更新時間:2018年09月21日 14:56:22 作者:ABC
這篇文章主要為大家詳細介紹了vue-quill-editor富文本編輯器簡單使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
文章剛開始先來介紹一下vue-quill-editor富文本編輯器的簡單使用,具體操作步驟如下:
安裝:
npm install vue-quill-editor --save
main.js:
import VueQuillEditor from 'vue-quill-editor' import 'quill/dist/quill.core.css' import 'quill/dist/quill.snow.css' import 'quill/dist/quill.bubble.css'
在需要使用的地方:
<template>
<quill-editor
v-model="content"
ref="myQuillEditor"
:options="editorOption"
@blur="onEditorBlur($event)"
@focus="onEditorFocus($event)"
@change="onEditorChange($event)">
</quill-editor>
</template>
<script>
import { quillEditor } from 'vue-quill-editor'
export default{
data(){
return {
content:null,
editorOption:{} //配置
}
},
methods:{
onEditorBlur(){//失去焦點事件
},
onEditorFocus(){//獲得焦點事件
},
onEditorChange(){//內(nèi)容改變事件
}
}
}
</script>
看到了一個網(wǎng)友分享的如何禁用vue-quill-editor 富文本編輯器,分享給大家,也謝謝原作者的分享。
vue:
<el-form-item label="描述:" :label-width="formLabelWidth"> <quill-editor v-model="form.content" ref="content" :options="editorOption" @blur="onEditorBlur($event)" @focus="onEditorFocus($event)" @change="onContentChange($event)" @ready="onEditorReady($event)"> </quill-editor> </el-form-item>
js:
export default {
data() {
form: {
content:'', // 存儲富文本框內(nèi)容
},
editorOption: { // 定義富文本編輯器顯示
modules:{
toolbar:[
['bold','italic','underline','strike'], // 加粗、傾斜、下劃線、刪除線
[{'header':1},{'header':2}], // 標題一、標題二
[{'list':'ordered'},{'list':'bullet'}], // 列表
[{'color':[]},{'background':[]}], // 字體顏色、背景顏色
]
}
}
},
methods: {
onEditorReady(){ // 富文本準備時的事件
},
onEditorFocus(val,editor){ // 富文本獲得焦點時的事件
console.log(val); // 富文本獲得焦點時的內(nèi)容
editor.enable(false); // 在獲取焦點的時候禁用
},
onEditorBlur(val){ // 富文本失去焦點時的事件
console.log(val); // 富文本失去焦點時的內(nèi)容
},
onContentChange(val){ // 富文本內(nèi)容改變時的事件
console.log(val); // 富文本改變時的內(nèi)容
}
}
}
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
相關(guān)文章
vue項目element?UI?版本升級過程遇到的問題及解決方案
這篇文章主要介紹了vue項目element?UI?版本升級過程遇到的問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-01-01

