相关文章推荐
爱运动的毛豆  ·  spring-boot-starter-va ...·  4 月前    · 
大鼻子的伤疤  ·  c# - Version conflict ...·  1 年前    · 

vue v-for遍历获取对象的key值

如果要获取key值的话就必须对对象进行v-for循环所以直接上代码吧。

<!DOCTYPE html>
		<meta charset="UTF-8">
		<title></title>
	</head>
		<div id="box">
				<li v-for="(val,i) in arr">
					<span v-for="(item,key,i) in arr[i]">
						{{key}} : 
						<span v-for="(item,key) in item[i]">
							{{key}} : {{item}}
						</span>
					</span>
	</body>
</html>
<script type="text/javascript" src="vue.js" ></script>
<script>
	new Vue({
		el:"#box",
		data:{
			arr:[
			{"apple":[{"color":"red","num":"265"}]},
			{"banana":[{"color":"yellow","num":"366"}]},
			{"pear":[{"color":"green","num":"896"}]}