const reader = new FileReader();
reader.readAsDataURL(file);
reader.onloadend = () => {
let newfile={
fileid:data?.id,
uid: file.uid,
name: file.name,
status: 'done',
response: JSON.stringify({ message: 'success' }),
url: reader.result,
thumbUrl: reader.result,
type: file.type,
size: file.size,
}
that.detailbak[index].fileList.push(newfile)
this.interfacenum--
this.removeHrefAttributes(index);
}
改成外链形式
// 使用 URL.createObjectURL 生成临时外链
const url = URL.createObjectURL(file);
// 构造新的文件对象
let newfile = {
fileid: data?.id, // 文件 ID
uid: file.uid, // 文件唯一标识
name: file.name, // 文件名
status: 'done', // 文件状态
response: JSON.stringify({ message: 'success' }), // 上传响应
url: url, // 外链 URL
thumbUrl: url, // 缩略图 URL
type: file.type, // 文件类型
size: file.size, // 文件大小
};
// 将新文件对象添加到文件列表中
that.detailbak[index].fileList.push(newfile);