vue 引進quill-image-resize-module 報錯TypeError: Cannot read property 'imports' of undefined
at Object.eval (image-resize.min.js?f318:1)
at e (image-resize.min.js?f318:1)
at Object.eval (image-resize.min.js?f318:1)
解決辦法:
1、在根目錄下新建vue.config.js 文件 (不是在src 下)
var webpack = require('webpack');
module.exports = {
// 在vue.config.js中configureWebpack中配置
// 要引入webpack
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
'window.Quill': 'quill/dist/quill.js',
'Quill': 'quill/dist/quill.js'
}),
]
}
}
2、mian.js
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);
3、頁面中
import { Quill } from 'vue-quill-editor'
import { ImageDrop } from 'quill-image-drop-module'
import ImageResize from 'quill-image-resize-module'
Quill.register('modules/imageDrop', ImageDrop)
Quill.register('modules/imageResize', ImageResize)
4、需要重新運行一下