当前位置:首页 > Web开发 > 正文

vue中能穿透组件的css选择器

2024-03-31 Web开发

如果父组件style设置了scoped,除了全局样式与子组件内部修改样式以外不受外部样式的影响,,但要是父组件想修改子组件某个地方的样式但又不想为了这么一点变动去添加个全局样式该怎么做呢?

这种情况可以使用带穿透功能的css选择器 >>>,如:

<style scoped> .nav >>> .component{   color: #f1f1f1; } >>> .component{   color: #fff; } </style>

与其作用相同的还有深度作用选择器/deep/

<style scoped> .nav /deep/ .component{   color: #f1f1f1; } /deep/ .component{   color: #fff; } </style>

vue中能穿透组件的css选择器

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/42227.html