在vue中有公共样式,有第三方样式,直接在mian.js中引入,在组件中scoped写的样式,需要在组件中局部修改公共样式,而又不想去除scoped属性造成组件之间的样式污染。有哪些方法呢?
办法一:使用::v-deep操作符
或者/deep/
/deep/ .el-form-item__label {
float: none;
}
::v-deep .el-form-item__label {
float: none;
}
办法二:使用>>>
外层 >>> 第三方组件
.wrapper >>> .swiper-pagination-bullet-active
background: #fff
办法三:使用全局sytle
在vue组件中使用两个style标签,一个加scoped属性,一个不加scoped属性,把需要覆盖的css样式写在不加scoped属性的style标签中。
<style lang="scss">
//给父元素加一个class类,修改公共样式
.paymentPlan .el-input__inner{
height: 36px;
line-height: 36px;
}
</style>
<style lang="scss" scoped>
.PaymentPlan {
margin: 0;
}
</style>