国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

vue富文本編輯器組件vue-quill-edit使用教程

2024-05-06 15:29:36
字體:
來源:轉載
供稿:網友

之前使用的富文本編輯器是uEditor,kindEditor,感覺不太方便。

近期項目vue單頁面,就使用vue-quill-edit這個編輯器組件吧!

一、安裝  cnpm install vue-quill-editor

二、引入

在main.js引入并注冊:

import VueQuillEditor from 'vue-quill-editor'// require styles 引入樣式import 'quill/dist/quill.core.css'import 'quill/dist/quill.snow.css'import 'quill/dist/quill.bubble.css'Vue.use(VueQuillEditor)

三、封裝組件

<template> <div class="quill_box"> <quill-editor  v-model="content"  ref="myQuillEditor"  :options="editorOption"  @blur="onEditorBlur($event)" @focus="onEditorFocus($event)" @change="onEditorChange($event)"> </quill-editor> </div> </template> <script>import Bus from "../../assets/utils/eventBus";export default { data() { return { content:'', editorOption: { placeholder: "請編輯內容", modules: {  toolbar: [  ["bold", "italic", "underline", "strike"],  ["blockquote", "code-block"],  [{ list: "ordered" }, { list: "bullet" }],  [{ script: "sub" }, { script: "super" }],  [{ indent: "-1" }, { indent: "+1" }],  [{ size: ["small", false, "large", "huge"] }],  [{ font: [] }],  [{ color: [] }, { background: [] }],  [{ align: [] }],  [ "image"]  ] } } }; }, props:[ 'contentDefault' ], watch:{ contentDefault:function(){ this.content = this.contentDefault; } }, mounted:function(){ this.content = this.contentDefault; }, methods: { onEditorBlur() { //失去焦點事件 // console.log('失去焦點'); }, onEditorFocus() { //獲得焦點事件 // console.log('獲得焦點事件'); }, onEditorChange() { //內容改變事件 // console.log('內容改變事件'); Bus.$emit('getEditorCode',this.content) } }};</script> <style lang="less"> .quill_box{ .ql-toolbar.ql-snow{border-color:#dcdfe6;} .ql-container{height:200px !important;border-color:#dcdfe6;} .ql-snow .ql-picker-label::before { position: relative; top: -10px; } .ql-snow .ql-color-picker .ql-picker-label svg, .ql-snow .ql-icon-picker .ql-picker-label svg{position: relative;top:-6px;} }</style>

四、引入使用

<my-editor :contentDefault="contentDefault"></my-editor>components:{ myEditor:myEditorComponent },

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持錯新站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 凌源市| 兴山县| 阿拉善盟| 临海市| 常州市| 长葛市| 丹凤县| 吴桥县| 鄂尔多斯市| 巩留县| 天等县| 南岸区| 六枝特区| 盐池县| 辉县市| 岐山县| 会理县| 沁阳市| 景谷| 新源县| 嵊州市| 长泰县| 随州市| 鱼台县| 丽江市| 汝州市| 贺州市| 勐海县| 独山县| 衡阳县| 绿春县| 光山县| 乐至县| 石台县| 霞浦县| 申扎县| 南充市| 隆安县| 阜康市| 府谷县| 应用必备|