vue2.0實(shí)現(xiàn)導(dǎo)航菜單切換效果
本文實(shí)例為大家分享了vue2.0實(shí)現(xiàn)導(dǎo)航菜單切換的具體代碼,供大家參考,具體內(nèi)容如下
css
*{ margin:0; padding: 0; } ul li{ list-style: none; } .navul{ margin:100px auto 20px; overflow: hidden; } .navul li{ background-color: #5597b4; padding:18px 30px; float:left; color: #fff; font-size: 18px; cursor: pointer; } .active{ background-color: #5597b4; } .home .home,.new .new,.contact .contact,.service .service{ background-color: skyblue; } .checked{ background: #eff4f7; }
html
<div id="nav"> <ul> <li v-for="(relation,index) in relations" v-bind:id="relation.id" v-bind:id="relation.id" v-bind:class="{checked:index==nowIndex}" v-on:click="relationClick(index)"> <i></i> <span class="">{{relation.text}}</span> </li> </ul> </div>
js
<script src="js/vue.js" charset="utf-8"></script> <script type="text/javascript"> var nav = new Vue({ el:'#nav', data:{ relations: [ {text:'項目',id:'program'}, {text:'人員',id:'person'}, {text:'機(jī)構(gòu)',id:'organization'}, {text:'技術(shù)',id:'tech'}, {text:'地區(qū)',id:'location'}, {text:'國家',id:'country'} ], nowIndex:-1, }, methods:{ relationClick:function(index){ this.nowIndex=index; } } }); </script>
效果圖:
關(guān)于vue.js組件的教程,請大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。
更多vue學(xué)習(xí)教程請閱讀專題《vue實(shí)戰(zhàn)教程》
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- vue-router+vuex addRoutes實(shí)現(xiàn)路由動態(tài)加載及菜單動態(tài)加載
- Vue.js 遞歸組件實(shí)現(xiàn)樹形菜單(實(shí)例分享)
- Vue.js組件tree實(shí)現(xiàn)無限級樹形菜單
- 基于vue.js實(shí)現(xiàn)側(cè)邊菜單欄
- vue addRoutes實(shí)現(xiàn)動態(tài)權(quán)限路由菜單的示例
- Vue實(shí)現(xiàn)導(dǎo)航欄菜單
- Vue在頁面右上角實(shí)現(xiàn)可懸浮/隱藏的系統(tǒng)菜單
- Vue 動態(tài)添加路由及生成菜單的方法示例
- vue2.0使用v-for循環(huán)制作多級嵌套菜單欄
- vue實(shí)現(xiàn)伸縮菜單功能
相關(guān)文章
Vue數(shù)據(jù)監(jiān)聽方法watch的使用
這篇文章主要介紹了Vue數(shù)據(jù)監(jiān)聽方法watch的使用,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-03vue2使用wangeditor實(shí)現(xiàn)數(shù)學(xué)公式和富文本編輯器
這篇文章主要為大家詳細(xì)介紹了vue2如何使用wangeditor實(shí)現(xiàn)數(shù)學(xué)公式和富文本編輯器功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2023-12-12vue+axios+promise實(shí)際開發(fā)用法詳解
這篇文章主要介紹了vue+axios+promise實(shí)際開發(fā)用法詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-10-10