qq_天会亮心会暧_0
2019-04-17 11:54
<template>
<ul>
<li v-for="(item,index) in lists"
@click="choose(index)"
:class="{active:index==current}"
:key="index">
{{item}}
</li>
</ul>
</template>
<script>
export default {
name:"demo1",
data() {
return {
lists: [1, 2, 3, 4, 5, 6, 7, 8, 9]
}
},
methods: {
choose(index){
console.log(index)
}
}
}
</script>
<style scoped>
li.active{
background: green;
}
</style>
原来是少写了个
current:''
0.0
3小时速成 Vue2.x 核心技术
82566 学习 · 499 问题
相似问题