思路: 上传成功以后,隐藏 .el-upload--picture-card
。
HTML部分
<el-upload :class="{hide_box: upload_btn}" :action="`#" list-type="picture-card" :on-success="handleSuccess" </el-upload>
script部分
<script setup lang="ts"> const upload_btn = ref(false) // 上传成功 const handleSuccess = () => { // 上传成功后,隐藏上传按钮 upload_btn.value = true } </script>
CSS 部分
.hide_box /deep/ .el-upload--picture-card { display: none; }
说明::on-success="handleSuccess"
这个是上传成功后触发,没成功不触发,如果没后台,只是想测试,可以换成 :on-change="handleSuccess"
,这个是状态修改后就触发