ElementUI上传控件clearFiles函数不可用

环境:
vue-cli
vue=2.6.10
ElementUI=^2.12.0

使用elmentui上传空间做了一个图片上传功能,代码如下:
`<ul>

              <li class="upload-item"
                  v-for="(item, index) in attachmentFileArr"
                  :key="index">
                <el-button icon="el-icon-error"
                           class="romove-item"
                           @click="reomveItem('attachment', index)"
                           circle></el-button>
                <div>
                  <el-upload action="/api/common/upload_file"
                             :ref="'ref_attachment_file_' + index"
                             :auto-upload="false"
                             :before-upload="beforeUpload"
                             :on-change="(file, fileList) => {hanldeFileChange(file, fileList, 'attachment', index)}"
                             :on-remove="(file, fileList) => {hanldeRemovefile(file, fileList, 'attachment', index)}"
                             :file-list="attachment_file_list[index]"
                             :on-progress="uploadFileProcess"
                             :on-success="(res, file) => {handleFileSuccess(res, file, 'attachment', index)}"
                             list-type="picture"
                             :limit="1">
                    <el-button type="primary"
                               class="btn-upload"
                               v-show="attachmentUploadBtnShow[index]">仅上传小于25M文件大文件<br />请上传百度云后填写链接
                    </el-button>
                    <span slot="tip"
                          class="tip_note"></span>
                  </el-upload>

                  <el-input type="textarea"
                            :rows="3"
                            v-model="attachment_desc[index]"
                            :ref="'ref_attachment_desc' + index"
                            placeholder="请描述该附件内容与作用"
                            @input.native="(event) => {saveFileDesc(event, 'attachment', index)}"></el-input>
                </div>
              </li>
            </ul>`
            

效果如下:
image.png

为什么使用
_this.$refs['ref_attachment_file_' + rowIndex].clearFiles()这个方法会报错呢?
查看函数报这个异常
image.png

已经尝试关闭严谨模式,但是没用~
求指点

阅读 5.7k
1 个回答

_this.$refs['ref_attachment_file_' + rowIndex][0].clearFiles()

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题