vxe-upload 上傳圖片顯示進度

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

官網:https://vxeui.com/

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

<script>
import axios from 'axios'
export default {
  data () {
    const imgList = []
    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 {
      imgList,
      uploadMethod
    }
  }
}
</script>

相關文章