element-ui 上传图片或视频时,先回显在上传

           <el-upload
              class="upload-demo"
              ref="vidos"
              :action="URL+'/api/post/file'"
              :data="date"
              :on-success="handleAvatarAUDIO"
              :before-upload="beforeAvatarAUDIO"
              :on-progress="beforeAvatarUpload"
              accept=".mp4"
              :on-change="AvatarAUDIO" //将用到次方法
              :file-list="fileList"
            >    

 

   AvatarAUDIO(file, fileList){
      // 此方法如果是大文件时会出现偶尔卡顿
      let reader = new FileReader()
      reader.readAsDataURL(file.raw)
      reader.onload=()=>{
          console.log(reader.result,'地址')
          this.AUDIO = reader.result
      }
      // 第二种方法
      let URL = window.URL || window.webkitURL;
      this.AUDIO = URL.createObjectURL(file.raw);

    },

  

原文地址:https://www.cnblogs.com/tlfe/p/12066779.html