Ant Design Upload 文件上传功能

本文介绍了如何在Ant Design Vue和React中实现文件上传功能,详细讲解了各自的文件上传选项框及其对应的JavaScript实现代码,旨在分享开发经验并提供帮助。
摘要由CSDN通过智能技术生成

Ant Design (vue,react)Upload文件上传功能

一、Ant Design Vue文件上传功能

  1. 文件上传选项框
 <a-modal
      title="上传文件"
      :footer="null"//不显示底部按钮
      :visible="visible"//是否显示
      :confirmLoading="confirmLoading"//确定按钮 loading
      @cancel="handleCancel"//取消方法
    >
      <a-upload
        :fileList="fileList"//上传的文件列表
        :remove="handleRemove"//文件删除方法
        :beforeUpload="beforeUpload"//上传文件之前的钩子,参数为上传的文件
      >
        <a-button>
          <a-icon type="upload" />选择文件
        </a-button>
      </a-upload>
    </a-modal>
<div class="streetAdd">
      <a-button type="primary" icon="plus" @click="engineeringadd()">新增</a-button>
      <a-button type="primary" icon="file" @click="showModal()">数据导入</a-button>
    </div>

效果:
在这里插入图片描述

在这里插入图片描述

  1. js实现代码
//定义的变量
<script>
export default {
   
	data() {
   
	    return {
   
	      visible: false,
	      confirmLoading: false,
	      fileList: [],
	      IpConfig: this.IpConfig.projectServiceDomain,
	    }
	  },
	mounted: function () {
   
	    this.engineeringList()
	    //that.alarmTypes=res.data.res.dictionaryList;
	  },
	   methods: {
   
		   //点击数据导入按钮所调用的方法
		    showModal() {
   
		      this.visible = true
		    },
		    //对话框确认方法
		    handleOk(e) {
   
		      this.visible = false
		      this.confirmLoading = false
		    },
		    //关闭弹框
		    handleCancel(e) {
   
		      //console.log('Clicked cancel button')
		      this.visible = false
		    },
		    //删除上传文件
		    handleRemove(file) {
   
		      const
  • 5
    点赞
  • 46
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值