当前位置:网站首页>深度(穿透)选择器 ::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 比较通用

边栏推荐
- 海量数据冷热分离方案与实践
- 查询商品案例-页面渲染数据
- Why is it not recommended to use BeanUtils in production?
- Common English Vocabulary
- 【数据挖掘】任务2:医学数据库MIMIC-III数据处理
- [error record] an error is reported in the fluent interface (no mediaquery widget ancestor found. | scaffold widgets require a mediaquery)
- Vim 9.0正式发布!新版脚本执行速度最高提升100倍
- 网络安全-NAT网络地址转换
- leetcode刷题_两数之和 II - 输入有序数组
- Network security - Trojan horse
猜你喜欢

串口抓包/截断工具的安装及使用详解
![[leetcode] 797 and 1189 (basis of graph theory)](/img/2a/9c0a904151a17c2d23dea9ad04dbfe.jpg)
[leetcode] 797 and 1189 (basis of graph theory)

A simple tool for analyzing fgui dependencies

STM32 - Application of external interrupt induction lamp

海量数据冷热分离方案与实践

Everything文件搜索工具
![[data mining] task 5: k-means/dbscan clustering: double square](/img/e7/678197e703d1a28b765a0e3afd5580.png)
[data mining] task 5: k-means/dbscan clustering: double square

Network security - vulnerabilities and Trojans

Telecom Customer Churn Prediction challenge
![[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道](/img/c6/9aee30cb935b203c7c62b12c822085.jpg)
[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道
随机推荐
SSL flood attack of DDoS attack
Network security OpenVAS
【数据挖掘】任务5:K-means/DBSCAN聚类:双层正方形
mysql
网络安全-木马
One of the C language practical projects is greedy snake
网络安全-病毒
小程序開發的部分功能
网络安全-中间人攻击
[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)
C语言课程信息管理系统
电信客户流失预测挑战赛
Why is it not recommended to use BeanUtils in production?
Sweet talk generator, regular greeting email machine... Open source programmers pay too much for this Valentine's day
Uniapp component -uni notice bar notice bar
STM32 - switch of relay control lamp
[技术发展-23]:DSP在未来融合网络中的应用
Take you ten days to easily complete the go micro service series (II)
Analysis, use and extension of open source API gateway apisex