姓名:{{data.nameList[index]}} _vue v-for 循环2个">
当前位置:   article > 正文

vue v-for一次循环两项_vue v-for 循环2个

vue v-for 循环2个

vue v-for一次循环两项

<template>
	<div>
		<!-- 只要姓名 一次循环两项只要第一个值-->
		<li v-for="(v,index) in data.nameList" v-if="index % 2 == 0">
			姓名:<span>{{data.nameList[index]}}</span>
		</li>
		<!-- 姓名与年龄 一次循环两项两个值都要-->
		<li v-for="(v,index) in data.nameList" v-if="index % 2 == 0">
			姓名:<span>{{data.nameList[index]}}</span>
			——————
			年龄:<span>{{data.nameList[index+1]}}</span>
		</li>
	</div>
</template>

<script>
export default {
    name: "test",
    watch:{
	
    },
    data() {
      return {
        data:{
			nameList:[
				"小明",3,
				"小红",4,
				"小李",5,
				"小丽",3,
				"小强",3,
				"老王",10
				]
		},
      };
    },
    mounted() {
	
    },
    methods: {
	
    }
  }
</script>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/76761
推荐阅读
相关标签
  

闽ICP备14008679号