这是一个案例 点击哪一个,哪一个就会变红
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
.isActive{
color:red;
}
</style>
<script src="./vue.js"></script>
</head>
<body>
<div id="root">
<ul>
<li v-for="(i , index) in movies" :class="{isActive:currentId===index}" @click="onTap(index)" >{{index}}-{{i}}</li>
</ul>
</div>
<script>
new Vue({
el:"#root",
data:{
currentId:0,
movies:["海王","海尔兄弟","海贼王","海神唐三"]
},
methods:{
onTap(index){
this.currentId=index;
}
}
})
</script>
</body>
</html>