如下代码有其他更好的写法吗?
<router-link :to="item.href" v-text="item.content" :class="item.current?hover:''"></router-link>
let navs=[
{
content:'首页',
current:false,
child:null
},{
content:'关于我们',
current:false,
child:{
show:true,
content:'简介'
}
},{
content:'联系我们',
current:false
}]
created:(){
let hash = window.loaction.hash;
if(hash.includes('index')){
this.navs[0].current = true;
}else if(hash.includes('about')){
this.navs[1].current = true;
}else if(hash.includes('connect')){
this.navs[2].current = true;
}
}
Map结构精简if else链接描述