vue-quill-editor 简单使用方法和注意事项


先安装组件

npm install vue-quill-editor
npm install quill

全局引入

import Vue from 'vue'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
  
Vue.use(VueQuillEditor)

或局部引入

import { quillEditor } from "vue-quill-editor";
// 导入富文本编辑器样式
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import Quill from "quill";

//组件引入部分
components: {
    quillEditor,
  },

使用样例

<quill-editor
          style="height:490px;width:100%;"
          v-model="html"
          ref="richAnalysis"
          :options="options"
        ></quill-editor>

符文编辑框的背景色和初始字体好像需要自己设置,theme的主题设置就有snow和bubble,用来控制是否显示工具栏的,

 

 

配置

options: {
        theme: "snow",
        placeholder: "请输入内容",
        modules: {
          toolbar: [
            ["bold", "italic", "underline", "strike"], // 加粗,斜体,下划线,删除线
            //['blockquote', 'code-block'],                      //引用,代码块
            [{ header: 1 }, { header: 2 }], // 几级标题
            [{ list: "ordered" }, { list: "bullet" }], // 有序列表,无序列表
            [{ script: "sub" }, { script: "super" }], // 下角标,上角标
            [{ indent: "-1" }, { indent: "+1" }], // 缩进
            //[{ direction: "rtl" }], // 文字输入方向
            [{ size: ["small", false, "large", "huge"] }], // 字体大小
            [{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
            [{ color: [] }, { background: [] }], // 颜色选择
            [{ font: [] }], // 字体
            [{ align: [] }], // 居中
            ["clean"],    //清除样式
            [("link", "image","video")],//控制能上传的内容
          ],
        },
      },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM