使用flex布局发现,如果规定了一行三个,使用flex-around之后,只有4个数据时最后一行会居中显示
解决思路,既然是flex布局,那么就补两个盒子就行了。
代码:
<div class="content-item" v-for="item in roomList" @click="jump(item.servicesId,item.money)">
<img v-if="picList.indexOf(item.icon.substring(item.icon.lastIndexOf(':')+1))!=-1" :src="require('./img/'+item.icon.substring(item.icon.lastIndexOf(':')+1)+'.png')" alt="">
<img v-else src="./img/iconfont.png" alt="">
<p v-text="item.servicesName?item.servicesName:item.name"></p>
</div>
<div v-for="item in 3-roomList.length%3" style="width: 7.5rem"></div>