上传图片提示用户图片正在上传中,请稍后
van-uploader组件默认没有提示,选择图片后直接显示在页面上,对于用户来说感知不到图片上传的进度和过程,如果上传失败用户也无法感知
打印上传的文件files查看属性
解决:给files中添加status和message属性
afterRead: async function(files) {
this.imgFile = new FormData();
this.imgFile.append('file', files.file);
files.status = "uploading";
files.message = "上传中...";
this.$API.common.uploadImg.post3(`?DeviceId=${this.DeviceId}`, this.imgFile).then(() => {
showToast('上传成功');
files.status = "";
}).catch(() => {
showToast('上传失败');
files.status = "";
this.fileList = [];
});
}
无论上传成功与否都将status设置为空,取消上传提示文字