功能:
展示數組元素及其索引
實現:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>v-show</title>
<!--引入vue-->
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>
<body>
<div id="myif">
<ul>
<li v-for="(item,index) of list">{{item}} , {{index}}</li>
</ul>
</div>
<script>
new Vue({
el:"#myif",
data:{
list:["xiaoming","jack","tom"]
}
})
</script>
</body>
</html>
運行結果: