直接上代码
:class="[index == menu_index?`menu_index${index}`:'']"
@click="menuClick(index)
data(){
return{
menu_img:'menu_index0',
menu_index:0
}}
menuClick(index){
this.menu_img = `menu_index${index}`
this.menu_index = index
}
css
.menu_index0{
background: url('/static/258img/chi_active.png') no-repeat !important;
}
.menu_index1{
background: url('/static/258img/he_active.png') no-repeat !important;
}
.menu_index2{
background: url('/static/258img/zhu_active.png') no-repeat !important;
}
.menu_index3{
background: url('/static/258img/wan_active.png') no-repeat !important;
}