1、设置样式:root { --border-width: 0px;}.el-upload-list { border: var(--border-width) solid red;}2、监听列表,判断是否显示边框 watch: { fileList: { deep: true, handler: function(newValue, oldValue) { let borderWidth = newValue.length ? "1px" : "0px"; document.getElementsByTagName('body')[0].style.setProperty('--border-width', borderWidth); } } }, 3、上传或移除时,fileList需重新赋值,否则无法监听数组的变化 handelSuccess(response, file, fileList){ this.fileList = fileList; }, handleRemove(file, fileList) { this.fileList = fileList; },
1、设置样式
:root {
--border-width: 0px;
}
.el-upload-list {
border: var(--border-width) solid red;
}
2、监听列表,判断是否显示边框
},
3、上传或移除时,fileList需重新赋值,否则无法监听数组的变化