解决方法
可以使用quill-image-paste,使用方式如下
import '../../assets/image-paste.min.js';
// 然后在data里的editorOption的modules中添加imagePaste
editorOption: {
modules: {
/* 还有一些其他的模块*/
imagePaste: {
addImageBlob: function (blob, callback) {
var formData = new FormData()
formData.append('file', blob)
// your upload function, get the uploaded image url, add then
let config = {
headers: {
"Content-Type":"multipart/form-data",
"Accept": "*/*"
}
}
// 上传接口
self.$http.post('/xxx/xxxx/xxx/', formData, config)
.then(res => {
var imageUrl = res.data.filepath // 服务器返回的图片url
callback(imageUrl)
})
}
}
}
},
参考:https://github.com/LiangCY/quill-image-paste