Odd and even row styles under vue v-for loop

<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>

effect

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43908123/article/details/108541715