Closed sailei1 closed 5 years ago
<template> <div class="footer"> <template v-for="item in menu"> <div class="btn" :class="{active: select == item.index,launch: item.icon=='launch'}"> <i class="icon" :class="setClass(item.icon)"></i> <p>{{item.title}}</p> </div> </template> </div> </template> export default{ data(){ return { select:0, menu:[ {icon:'home', title:'首页',index:0}, {icon:'find', title:'发现',index:1}, {icon:'launch', title:'发起',index:2}, {icon:'feed', title:'动态',index:3}, {icon:'my', title:'我',index:4}, ] } }, props:{ }, components:{}, methods:{ setClass(key){ let obj={}; if(key =='launch'){return obj} obj[`${key}`]=true; return obj; } }, }