<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>tab颜色切换</title>
<script src="js/vue.min.js"></script>
</head>
<body>
<style>
.aa{
cursor: pointer;float: left;margin: 0 6px;
}
.red{
color: red;
}
</style>
<div id="app">
<div v-for="(qiehuan,index) in qiehuans" class="aa" :class="{ red:changeRed == index}" @click="change(index)">{{qiehuan.a}}</div>
</div>
<script>
new Vue({
el:'#app',
data:{
qiehuans:[
{a:"田"},
{a:"心"},
{a:"水"},
{a:"原"}
],
changeRed:0
},
methods:{
change(index){
this.changeRed = index;
}
}
})
</script>
</body>
</html>