tinymce编辑器自定义上传图片报错
cannot read properties of undefined(read then)
这是因为tinymce6以后使用以前的上传方式不可用了
现在这个images_upload_handler需要返回一个promise对象
他的参数也和以前不一样了
这是以前的
images_upload_handler: (blobInfo: any, success: any, failure: any) => {
xxxxxxx
},
现在是这样
images_upload_handler: (blobInfo: any, progress: any)
他需要返回 一个promise对象,以下为完整的代码示例:
基本配置:
images_upload_handler: (blobInfo: any, progress: any) => handleImageUpload(blobInfo, progress),
handleImageUpload方法:
const handleImageUpload = async (blobInfo: any, progress: any) => {
let formData = new FormData();
formData.set('file', blobInfo.blob());
//调用自己实现的后台文件上传api
let imgObj = await uploadApi(formData)
return new Promise((resolve,reject)=>{
if(imgObj.inMap.code=='200'){
resolve(imgObj.inMap.fileUrl+imgObj.inMap.rowKey)
}else{
reject(imgObj.inMap.msg)
}
})
};
爆款云服务器s6 2核4G 低至0.46/天,具体规则查看活动详情