美文网首页
文件上传,显示进度条

文件上传,显示进度条

作者: Wrestle_Mania | 来源:发表于2020-04-23 23:54 被阅读0次
        async httpRequest(param) {
          let formData = new FormData()
          formData.append('file', param.file)
          const config = {
            onUploadProgress: progressEvent => {
              this.progress = Number(
                ((progressEvent.loaded / progressEvent.total) * 100).toFixed()
              )
            }
          }
          const { viewPath } = await FileUpload(formData, config)
          this.$message.success('脚本文件上传成功')
          this.form.kettlePath = viewPath
        },
    
    import request from '@/plugin/axios'
    
    const BASE_URL = 'sys/file'
    
    export function FileUpload(data, config) {
      return request({
        url: BASE_URL + '/upload',
        method: 'post',
        data,
        headers: { 'Content-Type': 'multipart/form-data' },
        ...config
      })
    }
    
    

    相关文章

      网友评论

          本文标题:文件上传,显示进度条

          本文链接:https://www.haomeiwen.com/subject/teytwhtx.html