<style scoped lang="less" scoped>
.el-form-item__label {
padding-top: 20px;
width: 100px !important;
}
</style>
如上图,如果不加 scoped,会影响其他组件的样式,加了后,会使CSS 无效,原因是 .el-form-item__label 是组件,scoped会限制css只在这个页面上起作用,为了穿透到子组件,必须要用 /deep/
<style scoped lang="less" scoped>
/deep/ .el-form-item__label {
padding-top: 20px;
width: 100px !important;
}
</style>