文章剛開始先來介紹一下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(){//內容改變事件      }    }  }</script>  看到了一個網友分享的如何禁用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:'', // 存儲富文本框內容    },    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); // 富文本獲得焦點時的內容      editor.enable(false); // 在獲取焦點的時候禁用    },    onEditorBlur(val){ // 富文本失去焦點時的事件      console.log(val); // 富文本失去焦點時的內容    },    onContentChange(val){ // 富文本內容改變時的事件      console.log(val); // 富文本改變時的內容    }  }}以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持錯新站長站。
新聞熱點
疑難解答
圖片精選