vxe-upload 上傳附件顯示進度

可不简单發表於2024-11-22

官網:https://vxeui.com/

<template>
  <div>
    <vxe-upload v-model="fileList" multiple show-progress :upload-method="uploadMethod"></vxe-upload>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  data () {
    const fileList = []
    const uploadMethod = ({ file }) => {
      const formData = new FormData()
      formData.append('file', file)
      return axios.post('/api/pub/upload/single', formData).then((res) => {
        return {
          ...res.data
        }
      })
    }
    return {
      fileList,
      uploadMethod
    }
  }
}
</script>

相關文章