老实说key值不能重复,为什么我测试的时候没有出问题?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/Vue.js" ></script>
</head>
<body>
<div id="div1">
<div v-show="show">
<div>Hello World</div>
</div>
<input type="button" value="toggle" @click="fn"/>
<ul>
<li v-for="item in list" v-bind:key="item">{{item}}</li>
</ul>
</div>
<script type="text/javascript">
new Vue({
el: "#div1",
data: {
show: true,
list: [1,2,2,4,2,1]
},
methods: {
fn: function(){
this.show = !this.show
}
}
})
</script>
</body>
</html>