<div v-for="item in list" :key="item.id" class="list-style">
<div class="item-style">
<p>{
{
item.preName}</p>
</div>
</div>
<style>
/* 奇数行的样式 */
.list-style:nth-child(odd)>.item-style {
background: #f8fbfd;
}
/* 偶数行的样式 */
.list-style:nth-child(even)>.item-style {
background: #666;
}
</style>
效果