<template>
<view>
<view
v-for="(item,index) in menus"
class="menu"
:class="[activeIndex==index?'menuActive':'']"
@click="menuClick"
:id="index">
{{item}}
</view>
</view>
</template>
<script>
var _self;
export default{
data(){
return{
activeIndex:0,
menus:[
'新闻',
'汽车',
'读书'
]
}
},
onLoad() {
_self=this;
},
methods:{
menuClick:function(e){
var aId=e.target.id;
_self.activeIndex=aId;
}
}
}
</script>