1.样式加scoped属性的作用:
<style>
标签添加了 scoped
属性,只作用于当前组件中的元素,
2.如何更改第三方组件的样式:用/deep/
使用深度作用选择器/deep/
,使用方式:将/deep/
+ space空格
添加在第三方样式类的前面。如果是使用less语法的话,直接在第三方样式的最外一层添加一遍/deep/就可以了
例子:
html:
<div class="pop_choose_price"> <van-collapse v-model="activeName" accordion> <van-collapse-item title="姓名分析 ¥588.00" name="1" class="gray" :class="{ current: activeName === '1' }">根据生辰八字,分析五行喜忌强弱、命格特点分析出阻碍运势的关键因素。</van-collapse-item> </van-collapse> </div>
css:
.pop_choose_price { height: 300px; overflow-y: auto; /deep/ .van-cell__title { color: #e35c57; padding-left: 20px; } /deep/ .van-collapse-item__content { color: #333; } .gray { /deep/ .van-cell__title { position: relative; &::before { content: ""; position: absolute; z-index: 2; left: -7px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; background: #dbd0bf; background-size: 15px 10px; border-radius: 50%; } } } .current { /deep/ .van-cell__title { position: relative; &::before { content: ""; position: absolute; z-index: 2; left: -7px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; } } } }