<!-- 点击添加字体颜色 -->
<style scoped>
.active {
color: red;
}
</style>
<div id="app-2">
<ul>
<li v-for="(item,index) in movies" :class="{active:index == isSelect}" @click="bindColor(index)">
{{index}}:{{item}}</li>
</ul>
</div>
<script>
new Vue({
el: "#app-2",
data: {
isSelect: false,
color: 'red',
movies: ['海贼王', '火影', '死神', '天空之城',]
},
methods: {
bindColor: function (index) {
console.log(index)
this.isSelect = index
}
}
})
</script>
【vue】 点击切换字体颜色
<!-- 点击添加字体颜色 --><style scoped>.active {color: red;}</style><div id="app-2"><ul><li v-for="(item,index) in movies" :class="{active:index == isSelect...
·
更多推荐
已为社区贡献9条内容
所有评论(0)