element-ui upload带参数上传文件

2023-05-25  本文已影响0人  洃冭鎯oo
<el-upload
  ref="upload"
  action=""
  :http-request="uploadFile"
>
    <el-button type="primary" size="small">上传</el-button>
</el-upload>

export default {
  data() {
    return { }
  },
  methods: {
    uploadFile(param) {
      const formData = new FormData()
      formData.append('file', param.file)
      const data = {} // 上传要携带的参数
      formData.append('data', data)
      obsUpload(formData).then(res => {
        console.log(res)
      })
    }
  }
}



上一篇下一篇

猜你喜欢

热点阅读