代码精简导航标识

如下代码有其他更好的写法吗?

 <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;
}
}
阅读 1.6k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题