<div v-for="(node,index) in circlesTemp" class="bgColorJq"
:class="(index + 1) % circlesTemp.length == 0 ?'noright':'margin-right-10'"
:style="{'background-color':node.bgColor}">
</div>
// 1、在vue中 class 与 :class 是不冲突的,
// 2、(index + 1) % circlesTemp.length == 0 ?'noright':'margin-right-10'" 这格是关键性代码,
//样式
<style>
.noright{
margin-right:0;
}
.margin-right-10{
margin-right:10px;
}
</style>
vue.js 中 v-for 循环动态循环的div,并列一排,如果使最后一个div没有margin-right:10px
最新推荐文章于 2024-03-26 17:18:41 发布