elementUI上传组件,上传单个文件后隐藏上传按钮

vue代码

<el-upload
            ref="AvatarUpload"
            list-type="picture-card"
            action=""
            accept=".jpg, .png"
            :limit="1"
            :auto-upload="false"
            :file-list="fileList"
            :on-change="handleUploadChange"
            :on-remove="handleUploadRemove"
        >
          <i slot="default" class="el-icon-plus"/>
          <div slot="tip" class="el-upload__tip">只能上传一张jpg/png文件</div>
        </el-upload>

js代码

// 隐藏上传按钮
this.$refs.AvatarUpload.$children[1].$el.style.display = 'none'
// 显示上传按钮
this.$refs.AvatarUpload.$children[1].$el.style.display = ''
// this.$refs.AvatarUpload.$children是一个包含上传按钮在内的数组,第一个是图片列表div,最后一个是上传按钮

PS:根据需要控制显隐

posted @ 2024-01-02 14:23  喵师傅  阅读(735)  评论(0编辑  收藏  举报