<template>
   <Menu mode="horizontal" theme="dark" :active-name="top_menu.active_name" @on-select="menuChange">
      <MenuItem :name="item.id" v-for="(item,index) in permissions_array" :key="index">
         <Icon :type="item.icon" />
         {{item.title}}
      </MenuItem>
   </Menu>
</template>

<script>
   export default{
      methods:{
         menuChange(name){
            const permissions = this.permissions_object;
            //跳转地址处理
            this.handleData(name,permissions,obj=>{
               this.$router.push(obj);
            });
         },

         //跳转地址获取(获取第一层下拉项的第一项)
         handleData(mid,permission,cb){
            let temp = {};
            if(permission){
               temp = permission[mid];
               if(temp.menus && temp.menus.length){
                  this.handleData(temp.menus[0].id,permission,cb);
               }else{
                  cb({
                     path: temp.path,
                     query: {mid:temp.id}
                  })
               }
            }
         },
      }
   }
</script>
