当前位置:网站首页>深度(穿透)选择器 ::v-deep/deep/及 > > >
深度(穿透)选择器 ::v-deep/deep/及 > > >
2022-07-03 01:22:00 【13少啊】
原文:深度(穿透)选择器 ::v-deep /deep/ 及 >>>_俺是老王的博客-CSDN博客_v-deep
在vue项目的开发过程,使用了ElementUI组件样式style使用了scope属性,当想要修改组件样式,发现直接修改不了,需去掉scope属性或者使用深度选择器才能去修改成功。去掉scope又会影响全局样式,针对这种情况,可以使用深度作用选择器(即样式穿透)。本文对深度选择器做一个记录。
1.当项目中使用的css原生样式,需要使用>>>深度选择器来修改,外用第三方组件的样式
<style lang="css" scoped>
.el-button >>> span{
color: '#f00'
}
</style>2.当项目中使用的css扩展语言是less,需要使用/deep/或者::v-deep深度选择器来修改 外用第三方组件的样式。
<style lang="less" scoped>
/deep/.el-button{
span{
color: '#f00'
}
}
.el-button::v-deep{
span{
color: '#f00'
}
}
</style>
3.当项目中使用的css扩展语言是node-sass,需要使用/deep/或者::v-deep 深度选择器来修改 外用第三方组件的样式。
<style lang="scss" scoped>
.el-button::v-deep{
span{
color: '#f00'
}
}
/deep/.el-button{
span{
color: '#f00'
}
}
</style>
4、当项目中使用的 css 扩展语言是 dart-sass, 需要使用 ::v-deep 深度选择器来修改 外用第三方组件的样式,dart-sass不支持 /deep/ 和 >>> 的写法。
<style lang="scss" scoped>
.el-button::v-deep{
span{
color: '#f00'
}
}
</style>
总结:
② vue3.0 中使用 /deep/ 会报错,更推荐使用 ::v-deep
③ 对于使用了 css 预处理器(scss 、sass、 less)时,深度选择器 ::v-deep 比较通用

边栏推荐
- View of MySQL
- 【Camera专题】手把手撸一份驱动 到 点亮Camera
- PS去除水印详解
- [untitled]
- Vim 9.0正式发布!新版脚本执行速度最高提升100倍
- 2022 financial product revenue ranking
- Everything file search tool
- 【数据挖掘】任务2:医学数据库MIMIC-III数据处理
- Huakaiyun | virtual host: IP, subnet mask, gateway, default gateway
- [error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)
猜你喜欢
![[QT] encapsulation of custom controls](/img/33/aa2ef625d1e51e945571c116a1f1a9.png)
[QT] encapsulation of custom controls

Smart management of Green Cities: Digital twin underground integrated pipe gallery platform

树形结构数据的处理

海量数据冷热分离方案与实践
![[leetcode] 797 and 1189 (basis of graph theory)](/img/2a/9c0a904151a17c2d23dea9ad04dbfe.jpg)
[leetcode] 797 and 1189 (basis of graph theory)
![[data mining] task 5: k-means/dbscan clustering: double square](/img/e7/678197e703d1a28b765a0e3afd5580.png)
[data mining] task 5: k-means/dbscan clustering: double square

Wireshark data analysis and forensics a.pacapng
![[error record] navigator operation requested with a context that does not include a naviga](/img/53/e28718970a2f7226ed53afa27f6725.jpg)
[error record] navigator operation requested with a context that does not include a naviga

A simple tool for analyzing fgui dependencies

STM32 - introduction of external interrupts exti and NVIC
随机推荐
View of MySQL
[data mining] task 5: k-means/dbscan clustering: double square
Certaines fonctionnalités du développement d'applets
Three core issues of concurrent programming - "deep understanding of high concurrent programming"
[keil5 debugging] debug is stuck in reset_ Handler solution
Network security - Information Collection
¢ growth path and experience sharing of getting an offer
Related concepts of GDB in embedded system
【QT】自定义控件的封装
串口抓包/截断工具的安装及使用详解
[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道
Network security - the simplest virus
【数据挖掘】任务1:距离计算
SSL flood attack of DDoS attack
Network security - cracking system passwords
[shutter] animation animation (animatedwidget animation use process | create animation controller | create animation | create animatedwidget animation component | animation operation)
网络安全-ACL访问控制列表
【Camera专题】Camera dtsi 完全解析
Network security - scan
Wireshark data analysis and forensics a.pacapng