使用quill-image-resize-module实现富文本中图片大小可修改的 *** 作
安装:
npm install quill-image-resize-module --save
使用:
import Quill from 'quill';
import { ImageResize } from 'quill-image-resize-module';
Quill.register('modules/imageResize', ImageResize);
const quill = new Quill(editor, {
// ...
modules: {
// ...
imageResize: { //添加
displayStyles: {
backgroundColor: 'black',
border: 'none',
color: 'white'
},
modules: [ 'Resize', 'DisplaySize' ]
},
}
});
这个时候控制台会出现错误:引入quill-image-resize-module的报错“Cannot read property ‘imports’ of undefined”
Cannot read property 'imports' of undefined"
Failed to mount component: template or render function not defined.
Cannot read property 'registerof undefined
’
module.exports = {
plugins: [
new webpack.ProvidePlugin({
// 在这儿添加下面两行
'window.Quill': 'quill/dist/quill.js',
'Quill': 'quill/dist/quill.js'
})
]
}
基于vue-cli创建,找不到webpack.base.conf.js;在vue.config.js中设置
module.exports = {
chainWebpack: config => {
config.plugin('provide').use(webpack.ProvidePlugin, [{
'window.Quill': 'quill/dist/quill.js',
'Quill': 'quill/dist/quill.js'
}]);
},
}
或者
module.exports = {
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
'window.Quill': 'quill/dist/quill.js',
'Quill': 'quill/dist/quill.js',
})
]
},
}
重启:npm run dev 即可
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)