vue3中使用v-for遍历数组,显示时使用,分割

1. 在vue项目中我们通常会使用v-for来遍历数组并显示,当显示为多个数据时就会需要想怎么用,来分隔开这些数据

algConfig.manualAncestors为你当前遍历的数组,index就是用来判断当前数组有几项

 <template v-for="(item, index) in algConfig.manualAncestors" :key="index" >
    {
   
   { (index == algConfig.manualAncestors?.length - 1 && item.name) || item.name + ","}}
</template>

2. 效果展示

猜你喜欢

转载自blog.csdn.net/m0_52761651/article/details/130014161