<template> <div> <div v-for='(item,index) in arr' v-bind:class='{bg:index==isactive}' @click='fn(index)'> {{item}} </div> </div> </template> <script> export default { data() { return { isactive:0, arr:['111','222','333','444'] } }, methods: { fn:function(index){ console.log(index); this.isactive=index; } }, } </script> <style scoped> /*点击文字变颜色*/ .bg{ color:pink; } </style>