vue点击切换css样式
vue动态点击切换css样式<template><div v-for="i in 5"class="el-personal":class="{active:isActive==i}"@click="show(i)">切换css样式</div></template><script>export default {data() {retu
·
vue动态点击切换css样式
<template>
<div v-for="i in 5"
class="el-personal"
:class="{active:isActive==i}"
@click="show(i)">
切换css样式
</div>
</template>
<script>
export default {
data() {
return {
isActive: 0,
}
},
methods: {
show(i) {
this.isActive = i
}
}
}
</script>
<style lang="scss" scoped>
.el-personal{
width:100px;
height:100px;
background:red;
}
.active{
background:blue;
}
</style>
更多推荐
已为社区贡献2条内容
所有评论(0)