当前位置:网站首页>Antd - a-upload-dragger drag upload component - Basic accumulation
Antd - a-upload-dragger drag upload component - Basic accumulation
2022-06-22 07:11:00 【yehaocheng520】
Recently, I'm doing background management system , One requirement is to implement drag and drop uploading .
At first I thought about using Ali oss Upload , But the requirement here is to upload locally .
The renderings are as follows :
1.antd Upload components on the official website :https://1x.antdv.com/components/upload-cn/
antd Official website upload component :https://1x.antdv.com/components/upload-cn/
2. Upload code
<a-upload-dragger
style=""
accept=".xlsx,.xls,.csv"
:file-list="form.file"
:remove="handleRemove"
:before-upload="beforeUpload"
>
<p class="ant-upload-drag-icon">
<a-icon type="inbox" />
</p>
<p class="ant-upload-text"> Please select upload file </p>
<p class="ant-upload-hint" style="color: red">
You can drag or select files , Please select a suffix .xlsx.xls Format file
</p>
</a-upload-dragger>
2.1 In the above form.file, This is an array type
2.2 beforeUpload Functions before uploading
beforeUpload(file) {
this.form.file = [...this.form.file, file];
return false;
},
2.3 handleRemove Function removed
handleRemove(file) {
const index = this.form.file.indexOf(file);
const newFileList = this.form.file.slice();
newFileList.splice(index, 1);
this.form.file = newFileList;
},
3. Save the code section
const formData = new FormData();
formData.append("file", this.form.file[0]);
// The following saved interface , This needs to be matched with the backend
this.confirmLoading = true;
postCheckPaySafeUpload(formData)
.then((res) => {
if(res.IsOk){
this.confirmLoading = false;
this.$message.success(" Successful operation ");
}else{
this.$message.error(res.Message)
}
})
.finally(() => {
this.confirmLoading = false;
});
complete !!!
边栏推荐
- Canoe learning notes (2) diagram of trace window introduction
- 6. 安装ssh连接工具(用于我们连接实验室的服务器)
- 一个算子在深度学习框架中的旅程
- RFID仓储管理系统解决方案实施可视化流程
- [out of distribution detection] deep analog detection with outlier exposure ICLR '19
- Solutions to newinstance() invalidation
- C语言——深入理解数组
- Sharing the strongest summer vacation plan of ape tutoring: the summer vacation plan is the same as learning and playing
- 从暴力递归到动态规划
- Programming problem: removing elements from an array (JS Implementation)
猜你喜欢

RT-Thread临界段的保护

Detailed tutorial on connecting MySQL with tableau

About structure (notes, for personal use)

MySQL面试真题(十九)——抖音-选出每个月有连续登录2天的用户名单

6. 安装ssh连接工具(用于我们连接实验室的服务器)

一个算子在深度学习框架中的旅程

Convolutional neural network (notes, for personal use)

CNN模型合集 | Resnet变种-WideResnet解读
![[meta learning] classic work MAML and reply (Demo understands meta learning mechanism)](/img/e5/ea68e197834ddcfe10a14e631c68d6.jpg)
[meta learning] classic work MAML and reply (Demo understands meta learning mechanism)

Use of sessionstorage and localstorage
随机推荐
Error when connecting MySQL with dbeaver for the first time
【GAN】SentiGAN IJCAI’18 Distinguished Paper
buuctf部分题目wp
校招路上的坑
JDBC query result set, which is converted into a table
Custom implementation of bind method in JS
JS中对数组进行去重的几种方法
Cesium加载3D Tiles模型
Up sampling and down sampling (notes, for personal use)
Successfully solved raise keyerror (F "none of [{key}] are in the [{axis\u name}]") keyerror: "none of [index (['age.in.y
[fundamentals of machine learning 04] matrix factorization
golang调用sdl2,播放pcm音频,报错signal arrived during external code execution。
Tikz learning notes (IV) further exploration of circle and complex geometry
Golang appelle sdl2, lit l'audio PCM et signale une erreur lors de l'exécution externe du Code.
C language - deep understanding of arrays
[outside distribution detection] your classifier is secret an energy based model and you head treat it like one ICLR '20
RFID仓储管理系统解决方案实施可视化流程
Process engine solves complex business problems
The solution of word document being locked and unable to edit
CONDA installation method of deepmd kit and the solution of slow speed