Blogger Information
Blog 250
fans 3
comment 0
visits 321550
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Vue自学:v-on遍历数组和对象
梁凯达的博客
Original
1648 people have browsed it

<!DOCTYPE html>

<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>Vue自学:v-on遍历数组和对象</title>
</head>
<body>
<div id="app">
<!-- v-for使用数组方式进行遍历,item代表值,index代表键 -->
<ul>
<li v-for="(item,index) in obj">{{item}}</li>
</ul>
<!-- v-for使用对象方式进行遍历,value代表值,item代表键,index代表索引序列 -->
<ul>
<li v-for="(value,item,index) in info">value={{value}} || item={{item}} || index = {{index}}</li>
</ul>
</div>
</body>
<script type="text/javascript">
const app = new Vue({
el:’#app’,
data:{
//数组写法 arr:[‘value’,’value’]
obj:[‘a’,’b’,’c’,’d’,’f’,’g’],
//对象写法 obj:{name:’value’,key:’value’}
info:{
name:’wo’,
height:’170cm’,
}
}
})
</script>
</html>

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post