Vue.js home PC-side horizontal navigation bar

Source: Internet
Author: User

First look at the effect

<template>
<div>
<div class= "NAV" >
<ul class= "Nav-centent" >
<li v-for= "(item, index) in items" @mouseover = "Selectstyle (item)" @mouseout = "Outstyle (item)" >
<a:href= "Item.href": class= "Item.id" >{{item.name}}</a>
<ul v-show= "Item.issubshow" >
<li v-for= "SubItems in Item.subitems" >
<a href= "#" >{{subItems.name}}</a>
</li>
</ul>
</li>
</ul>
</div>
</div>

</template>
<script type= "Text/javascript" >
Export default{
Data () {
return{
nowindex:0,
items:[
{
Name: ' Home ',
Issubshow:false,
subitems:[
]
},
{
Name: ' Select Route ',
Issubshow:false,
subitems:[
{
Name: ' Maldives '
},
{
Name: ' Somalia Strait '
},
{
Name: ' Lijiang/Kunming '
},
{
Name: ' Tiananmen Square/Forbidden City '
}
]
}
,
{
Name: ' About Us ',
Issubshow:false,
subitems:[
{
Name: ' Company Profile '
},
{
Name: ' Future Planning '
},
{
Name: ' Enterprise News '
}
]
},
{
Name: ' Travel guide ',
Issubshow:false,
subitems:[
{
Name: ' Popular Raiders '
},
{
Name: ' Economic strategy '
},
{
Name: ' Youth Raiders '
},
{
Name: ' Old age Raiders '
},
{
Name: ' Foodie must see '
}
]
},
{
Name: ' Custom Travel ',
Issubshow:false,
subitems:[
{
Name: ' Normal Custom '
},
{
Name: ' Deluxe line '
},
{
Name: ' A Must for lovers '
}
]
}

]
}
},
methods:{
Selectstyle:function (item) {
Item.issubshow = True
},
Outstyle (item) {
Item.issubshow = False
}
}
}

</script>
<style type= "Text/css" scoped>
. Nav{width:100%;height:50px;background: #48B246;}
. Nav. nav-centent{width:1200px;margin:0 auto;height:50px;}
. Nav. nav-centent > li{width:120px;height:50px;display:block;float:left;text-align:center;margin-right:20px; Position:relative;cursor:pointer;}
. Nav. nav-centent li A{width:120px;height:50px;display:block;font-size:18px;line-height:50px;color: #fff;}
. Nav. Nav-centent ul{position:absolute;left:0;top:50px;z-index:99;width:100%;}
. Nav. nav-centent ul li{width:120px;height:50px;display:block;float:left;text-align:center;margin-right:20px; Line-height:50px;background: #46B148;}
. Nav. nav-centent ul li a:hover{background: #fff; color: #48B246;}
. Nav. nav-centent li a:hover{background: #fff; color: #48B246;}
. Nav. nav-centent li a.on{background: #fff; color: #48B246;}


</style>

Just started to learn, write bad please God don't spray me.

Vue.js home PC-side horizontal navigation bar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.