0

vue-cli3项目,使用vue-editor-quill配合quill-image-resize-module,报错:

quill Cannot import modules/ImageResize. Are you sure it was registered?
[Vue warn]: Error in mounted hook: "TypeError: moduleClass is not a constructor"

上网搜的、看github里面的解决方案都试过,但仍旧报错,以下是我的代码,求个解决方案。
vue.config.js配置文件代码:

const webpack = require('webpack')
module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.ProvidePlugin({
        'window.Quill': 'quill/dist/quill.js',
        'Quill': 'quill/dist/quill.js'
      })
    ]
  }

demo.vue组件引入resize-module的代码:

import Quill from 'quill'
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 { container, ImageExtend, QuillWatch } from 'quill-image-extend-module'
import ImageResize from 'quill-image-resize-module'
Quill.register('modules/ImageExtend', ImageExtend)
Quill.register('modules/imageResize', ImageResize)
CBCzed 70
2019-07-14 提问
1 个回答
0

已采纳

折腾了一天,最后在github上看到了一个验证,就是引入import ImageResize from 'quill-image-resize-module'时首字母需要小写;改成这样
import imageResize from 'quill-image-resize-module'
Quill.register('modules/imageResize', imageResize)
这样就可以了

撰写答案

推广链接