如果你希望scoped样式中的一个选择器能够作用的更深,可以使用>>>操作符
<style scoped>
.json-editor{
height: 100%;
position: relative;
}
.json-editor >>> .CodeMirror {
height: auto;
min-height: 300px;
}
.json-editor >>> .CodeMirror-scroll{
min-height: 300px;
}
.json-editor >>> .cm-s-rubyblue span.cm-string {
color: #F08047;
}
</style>
但是想Sass之类的预处理器无法正确解析>>>,这种情况你可以使用/deep/或 ::v-deep操作符取而带之,两者都是>>>的别名,同样可以正常操作,一般我们把这种情况运用在更改elelmentui组件自带的样式时使用
.showRequired {
/deep/ .el-form-item__label::before {
content: '*';
color: #e63232;
margin-right: 4px;
}
}
.hiddenRequired {
/deep/ .el-form-item__label::before {
content: '' !important;
color: #e63232;
margin-right: 4px;
}
}
vue3.0使用less或者sass预处理器使用::v-deep深度选择器抛出如下警告
[@vue/compiler-sfc] ::v-deep usage as a combinator has been deprecated. Use :deep(<inner-selector>) instead.
原因新的vue3.0 单文件规范::v-deep写法已经被废弃了
修改成 如下写法,不要加空格
.xtx-carousel {
::v-deep(.carousel-btn.prev) {
left: 270px;
}
::v-deep(.carousel-indicator) {
padding-left: 250px;
}