记录一下 quillEditor 富文本的使用

<template>
  <div class="prefixCls">
    <div>
      <quill-editor
        class="editor"
        ref="myTextEditor"
        v-model="form.content"
        :options="editorOption"
        @blur="onEditorBlur($event)"
        @focus="onEditorFocus($event)"
        @ready="onEditorReady($event)"
        @change="onEditorChange($event)"
      >
        <!-- <div v-html="editorContent" class="richTextStyle"></div> -->
      </quill-editor>
      <!-- 隐藏上传图片按钮 -->
      <div style="display: none">
        <el-upload
          action="xxxx"
          multiple
          :limit="3"
          :on-success="handleSuccess"
          :before-upload="beforeAvatarUpload"
          ref="upload"
        >
          <el-button size="small" type="primary">11</el-button>
        </el-upload>
      </div>
    </div>
  </div>
</template>

<script>
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import option from "./option";
import toolbar from "./toolbar";
import { quillEditor } from "vue-quill-editor";
export default {
  name: "QuillEditor",
  components: {
    quillEditor,
  },
  props: {},
  data() {
    const bindings = {
      custom: {
        key: 13,
        handler: function (range, context) {
          this.quill.insertText(range.index, "\n ");
          setTimeout(() => {
            let nowRange = this.quill.getSelection().index - 1;
            this.quill.setSelection(nowRange);
          }, 0);
        },
      },
    };
    return {
      editorOption: {
        modules: {
          keyboard: {
            bindings: bindings,
          },
          toolbar: {
            container: toolbar,
            handlers: {
              image: function (value) {
                if (value) {
                  console.log(value);
                  document.querySelector(".el-button").click();
                } else {
                  this.quill.format("image", false);
                }
              },
            },
          }, //工具菜单栏配置
        },
        placeholder: "请在这里添加产品描述", //提示
        readyOnly: false, //是否只读
        theme: "snow", //主题 snow/bubble
        syntax: true, //语法检测
      },
      aa: "//lmg.jj20.com/up/allimg/4k/s/02/2109242332225H9-0-lp.jpg",
      dialogVisible: false,
      form: {
        // 提交表单
        title: "",
        con
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值