样式穿透和uniapp下的uni_modules里面组件的样式

一、原因

1、使用 scoped 后,父组件的样式将不会渗透到子组件中

2、scoped作用:避免样式污染

二、解决方案:样式穿透(修改子组件的默认样式)

1、::v-deep (必须是双冒号)【建议使用此方案:/deep/在某些时候会报错,::v-deep更保险且编译速度更快

2、/deep/

三、写法

1、vue3

::v-deep(.el-icon){ height: inherit; }

/deep/ .el-icon{ height: inherit; }

2、uniapp

::v-deep .uni-input-input {}

猜你喜欢

转载自blog.csdn.net/qq_39029949/article/details/130628027