富文本编辑器 配置 uploadAttachment: { // 自定义上传附件 async customUpload(file: File, insertFn: any) { try { const formData = new FormData(); formData.append('file', file); fetchApi(uploadImgFile, { param: formData, onRequestSuccessfull: (ret: any) => { const url = fileSever + ret?.result?.name; const alt = ret?.result?.originalName; const href = fileSever + ret?.result?.name; insertFn(url, alt || '', href || ''); }, }); } catch (error) { console.log(error); } }, }, 还会报错没有配置上传地址
时间: 2024-02-10 13:09:10 浏览: 140
Async/Await替代Promise的6个理由
根据您提供的代码,您的上传附件插件配置似乎没有包含`uploadUrl`字段,这可能是报错“没有配置上传地址”的原因。请将您的上传附件插件配置中添加`uploadUrl`字段,并将其设置为您后端的上传接口地址,例如:
```
uploadAttachment: {
// 自定义上传附件
async customUpload(file: File, insertFn: any) {
try {
const formData = new FormData();
formData.append('file', file);
fetchApi(uploadImgFile, {
param: formData,
onRequestSuccessfull: (ret: any) => {
const url = fileSever + ret?.result?.name;
const alt = ret?.result?.originalName;
const href = fileSever + ret?.result?.name;
insertFn(url, alt || '', href || '');
},
});
} catch (error) {
console.log(error);
}
},
// 添加uploadUrl字段
uploadUrl: 'your-upload-url',
},
```
请将`your-upload-url`替换为您后端的上传接口地址。希望这个解决方案能够帮助您解决问题。
阅读全文