一、使用images_upload_handler 自定义上传图片
在配置项initEditor里面添加
images_upload_handler: this.handlerAddImg
方法methods:
handlerAddImg (blobInfo, progress) {
return new Promise((resolve, reject) => {
const formData = new FormData()
formData.append('file', blobInfo.blob())
this.$api.addPicture(formData).then(res => { // 上传api
if (res.code === 200) {
resolve('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Ffile03.16sucai.com%2F2017%2F1100%2F16sucai_p20161119050_0fe.JPG&refer=http%3A%2F%2Ffile03.16sucai.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1664341021&t=7bcac9962924f3d12102b1417f6a67d7')
} else {
reject(res?.msg)
}
}).catch(res => {
reject(res)
})
})
网友评论