vue + elementsUI---el-upload上传时给个提示confirm判断

这段代码展示了如何在Vue应用中实现Excel文件上传,并在用户确认后调用导入接口进行处理。`beforeUpload`函数用于处理文件,通过FormData添加文件,并在弹窗确认后发送请求到TextItemImport接口。
摘要由CSDN通过智能技术生成
<el-upload
  class="upload-demo"
  ref="fileExcel"
  action="/"
  accept=".xlsx, .xls"
  :before-upload="beforeUpload"
>
  <el-button type="primary">导入</el-button>
</el-upload>
// 上传
    beforeUpload(file) {
      console.log('file',file)
      let formData = new FormData()
      formData.append('file', file)
      this.$confirm('确认导入吗?', '提示', { type: 'warning' })
        .then(() => {
          TextItemImport(formData).then(res => {
            if (res.success === true) {
              this.$message({ type: 'success', message: '导入成功!' })
              this.getDataList()
            } else {
              this.$message({ type: 'error', message: res.errormsg })
            }
          })
        })
        .catch(err => {})
    },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值