其他分享
首页 > 其他分享> > vue使用富文本编辑器

vue使用富文本编辑器

作者:互联网

一、安装依赖

npm install vue-quill-editor --save
npm install quill-image-extend-module --save-dev

二、使用编辑器

<template>
  <div class="quill-wrap">
    <quill-editor ref="myQuillEditor" v-model="content" :options="editorOption" />
  </div>
</template>
<script>
import 'quill/dist/quill.snow.css'
import { quillEditor, Quill } from 'vue-quill-editor'
import { container, ImageExtend, QuillWatch } from 'quill-image-extend-module'
Quill.register('modules/ImageExtend', ImageExtend)
export default {
  components: { quillEditor },
  data() {
    return {
      content: '',
      editorOption: { // 富文本框参数设置
        modules: {
          ImageExtend: {
            loading: true,
            name: 'img',
            action: 'http://127.0.0.1:7001/yun/upload',
            response: (res) => {
              return `http://127.0.0.1:7001/public/uploadfile/${res.data.filename}`
            }
          },
          toolbar: {
            container: container,
            handlers: {
              'image': function () {
                QuillWatch.emit(this.quill.id)
              }
            }
          }
        }
      }
    }
  }
}
</script>
<style>
.ql-container {
  min-height: 300px;
}
.quill-editor {
  width: 880px;
}
</style>

标签:ImageExtend,文本编辑,vue,container,image,editor,使用,import,quill
来源: https://blog.csdn.net/pgzero/article/details/122765029