elementUI为什么这样指定类名样式无效?
一共循环的是6个元素 css里面设置1的时候全部颜色都变成了蓝色 设置2的时候没有背景色 这是为什么?为什么不是我设置第几个第几个就变成蓝色呢?
<el-col class="total" v-for="(item, index) in parkArr" :key="item" :span="4">
<div class="default-grid-content">
<div class="default-grid-title">{{ item.title }}</div>
<div class="default-grid-body" :style="item.style">
{{ index > 0 ? "¥" : "" }}{{ item.desc }}
</div>
</div>
</el-col>
.default-grid-content:nth-of-type(2){
background-color: blue;
}
回复
1个回答

test
2024-07-17
ele:nth-of-type(n)表示选择父元素下的第 n 个ele 元素,.default-grid-content的父元素就它一个子元素
回复

适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容