vue2 的版本 使用 Ant Design Vue 1.78版本的组件库 做自定义接口 调用后端的接口上传excel文件

话不多说 上代码

<a-upload
style="margin-left: 8px"
:before-upload="beforeUpload"
:showUploadList="false"
:multiple="false"
:headers="tokenHeader"
>
   <a-button> <a-icon type="upload" /> 导入 </a-button>
</a-upload>

 提示内容可以根据自己的来

formData是二进制文件流传给后端的

exportUser:后端提供的接口

   
import { Modal} from 'ant-design-vue'

beforeUpload(file) {
      const formData = new FormData()
      formData.append('file', file)
      exportUser(formData).then((res) => {
        if (res.code == 200) {
          Modal.success({
            title: '系统提示',
            content: res.message,
            okText: '知道了',
          })
        } else {
          Modal.error({
            title: '系统提示',
            content: res.message,
            okText: '知道了',
          })
        }
      })
      this.getList()
      return false
    },

export function exportUser(data){
  return axios({
    url: '/schedule/createImport',
    data: data,
    method:'post',
  })
}

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-13 07:40:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-13 07:40:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-13 07:40:01       82 阅读
  4. Python语言-面向对象

    2024-04-13 07:40:01       91 阅读

热门阅读

  1. Leetcode 56. 合并区间和Leetcode 240. 搜索二维矩阵 II

    2024-04-13 07:40:01       41 阅读
  2. CentOS7.9.2009设置kibana7.11.1开机自启动

    2024-04-13 07:40:01       40 阅读
  3. C++基础——运算符重载

    2024-04-13 07:40:01       45 阅读
  4. Swagger2

    2024-04-13 07:40:01       148 阅读
  5. 【Apache】Apache 如何使用其他端口

    2024-04-13 07:40:01       42 阅读
  6. 使用cloudflare之后IP不对的问题

    2024-04-13 07:40:01       129 阅读
  7. C#:24小时制和12小时制之间的转换

    2024-04-13 07:40:01       31 阅读