element-ui上传组件el-upload- 编辑文件回显

         <el-upload
              ref="upload"
              class="upload-demo"
              :limit="1"
              action=""
              accept=".png,.jpeg,.pdf,.xlsx"
              :http-request="handleChange"
              :before-remove="beforeremove"
              :file-list="uploadFileList"
              :on-preview="clickFile"
              :show-file-list="true"
            >
              <div class="uploadFiles">   <img src="@/assets/overview/Vector.png">上传文件</div>
            </el-upload></div>

回显文件数组uploadFileList 不能使用 uploadFileList [0]赋值,无法监听到文件的变化,要使用push等数组方法

      if (fileUrl) {
        this.$nextTick(() => {
          console.log('dsadasds', this.detailItem)
          this.uploadFileList.push(
            {
              url: fileUrl,
              name: fileName
            }
          )
          this.$forceUpdate()
        })
      } else {
        this.uploadFileList = []
        this.$forceUpdate()
      }

你可能感兴趣的:(vue,vue.js)