当前位置:网站首页>深度(穿透)选择器 ::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 比较通用
边栏推荐
- Everything文件搜索工具
- 网络安全-动态路由协议RIP
- Network security OpenVAS
- NCTF 2018 part Title WP (1)
- [shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
- Network security - Information Collection
- 【Camera专题】OTP数据如何保存在自定义节点中
- Huakaiyun (Zhiyin) | virtual host: what is a virtual host
- [Appendix 6 Application of reflection] Application of reflection: dynamic agent
- Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
猜你喜欢
小程序开发的部分功能
STM32 - introduction of external interrupts exti and NVIC
QTableWidget懒加载剩内存,不卡!
【Camera专题】OTP数据如何保存在自定义节点中
电信客户流失预测挑战赛
Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
海量数据冷热分离方案与实践
自定义组件、使用npm包、全局数据共享、分包
[data mining] task 2: mimic-iii data processing of medical database
Scheme and practice of cold and hot separation of massive data
随机推荐
High-Resolution Network (篇一):原理刨析
[Appendix 6 Application of reflection] Application of reflection: dynamic agent
C application interface development foundation - form control (4) - selection control
leetcode刷题_两数之和 II - 输入有序数组
[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
网络安全-DNS欺骗与钓鱼网站
云原生题目整理(待更新)
Network security - phishing
网络安全-中间人攻击
[error record] navigator operation requested with a context that does not include a naviga
C#应用程序界面开发基础——窗体控制(1)——Form窗体
[data mining] task 1: distance calculation
QTableWidget懒加载剩内存,不卡!
What is tone. Diao's story
[AUTOSAR cantp] -2.11-uds diagnostic response frame data segment data padding data filling and data optimization data optimization (Theory + configuration)
View of MySQL
VIM 9.0 is officially released! The execution speed of the new script can be increased by up to 100 times
STM32 - Application of external interrupt induction lamp
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance o
网络安全-破解系统密码