在vue中使用element-ui库的时候,经常会遇到样式污染问题;
在单页面中使用<style scoped></style>,可以在当前页效果,但是修改的element-ui的效果却出了问题;
解决方案:
1:使用/deep/样式穿透
newUploadClass 是我定义的class
.newUploadClass /deep/ .el-upload-list .el-upload-list__item img {
width: 56px;
height: 35px;
}
2:使用>>>穿透
.newUploadClass >>> .el-upload-list .el-upload-list__item img {
width: 56px;
height: 35px;
}
3:如果element-ui的样式为行内,使用穿透的情况下再加上!important来增加权重
.newUploadClass /deep/ .el-upload-list .el-upload-list__item img {
width: 56px;
height: 35px;
margin-top: 4vh !important;
}