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

话不多说 上代码

html 复制代码
<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:后端提供的接口

javascript 复制代码
   
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
    },
javascript 复制代码
export function exportUser(data){
  return axios({
    url: '/schedule/createImport',
    data: data,
    method:'post',
  })
}
相关推荐
2601_958492552 小时前
Optimizing Engagement with Freehead Skate - HTML5 Game - Construct 3
前端·html·html5
茉莉玫瑰花茶2 小时前
工作流的常见模式 [ 1 ]
java·服务器·前端
zhangxingchao3 小时前
AI应用开发六:企业知识库
前端·人工智能·后端
山峰哥3 小时前
SQL慢查询调优实战:从全表扫描到索引覆盖的完整复盘
前端·数据库·sql·性能优化
红尘散仙4 小时前
一个 `#[uniffi::export]`,把 Rust 接进 React Native
前端·后端·rust
moshuying4 小时前
AI Coding 最大的 token 黑洞,可能根本不是 prompt
前端
红尘散仙4 小时前
一行 `#[specta::specta]`,让 Tauri IPC 有类型
前端·后端·rust
lichenyang4534 小时前
HarmonyOS HMRouter 接入记录:从普通 Tab Demo 到路由跳转
前端
流形填表4 小时前
大风车Excel|本地版软件下载与使用教程(2026最新版)
excel