最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue使用vuex實(shí)現(xiàn)首頁導(dǎo)航切換不同路由的方法

 更新時(shí)間:2019年05月08日 09:25:56   作者:遇你溫柔如初  
這篇文章主要介紹了vue使用vuex實(shí)現(xiàn)首頁導(dǎo)航切換不同路由的方法 ,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

vue實(shí)現(xiàn)首頁導(dǎo)航切換不同路由的方式(二)【使用vuex實(shí)現(xiàn)的】,具體代碼如下所示:

<nav>
    <!-- 導(dǎo)航欄 -->
   <div class="indexNavOut">
    <div class="indexNav">
    <ul class="navLi">
     <li @click="checkNav()" style="width: 130px;"><router-link to="/home">了解海華教育(視頻)</router-link><!--<a href="#">了解海華教育(視頻)</a>--></li>
     <li @click="checkNav()" v-bind:class="{'active':Index=='#/home','active2':Index=='#/'}">
      <router-link to="/home">首頁</router-link>
     </li>
     <li @click="checkNav()" v-bind:class="{'active':Index=='#/synopsis'}"><router-link to="/synopsis">學(xué)校簡介</router-link>
     </li>
     <li @click="checkNav()" v-bind:class="{'active':Index=='#/major'}"><router-link to="/major">專業(yè)介紹</router-link>
     </li>
     <li @click="checkNav()" v-bind:class="{'active':Index=='#/campus'}"><router-link to="/campus">校園風(fēng)采</router-link>
     </li>
     <li @click="checkNav()" v-bind:class="{'active':Index=='#/news'}"><router-link to="/news">新聞資訊</router-link>
     </li>
     <li @click="checkNav()" v-bind:class="{'active':Index=='#/enrollment'}"><router-link to="/enrollment">招生信息</router-link>
     </li>
     <li @click="checkNav()" v-bind:class="{'active':Index=='#/employment'}"><router-link to="/employment">就業(yè)中心</router-link>
     </li>
     <li @click="checkNav()" v-bind:class="{'active':Index=='#/enlist'}"><router-link to="/enlist">在線報(bào)名</router-link>
     </li>
     <li @click="checkNav()" v-bind:class="{'active':Index=='#/contact'}"><router-link to="/contact">聯(lián)系我們</router-link>
     </li>
    </ul>
    </div>
   </div>
   </nav>

css:

/* 導(dǎo)航欄 */
.indexNavOut{
 background-color: #486B8A;
 height: 60px;
}
.indexNav{
 width: 80%;
 margin: 0 auto;
}
.navLi{
 display: flex;
}
.navLi li:nth-child(1){
 flex: 1.8;
}
.navLi li{
 flex: 1;
}
.navLi li a{
 text-decoration: none;
 color: #fff;
 font-size: 16px;
 padding-bottom: 17px;
}
.indexNav .icon{
 width: 230px;
 margin-top: 10px;
}
.indexNav .icon img{
 width: 100%;
}
.navLi li {
 height: 60px;
 line-height: 60px;
 position: relative;
}
.navLi li.active a{
 border-bottom: 3px solid #E96463;
}
.navLi li.active2 a{
 border-bottom: 3px solid #E96463;
}
.navLi li:last-child:after{
 border-right: none;
}
.navLi li .line{
 width: 20px;
 height: 3px;
 background: #E96463;
 border: none;
 position: absolute;
 /*top: -14px;*/
 /*right: -32px;*/
 left: 50px;
 top: 45px; 
 z-index: 100;
}

js:

 main.js代碼:

import Vuex from 'vuex'
Vue.use(Vuex);
const store = new Vuex.Store({
 state: {
 majorDetail: false,
 Index: document.location.hash,//導(dǎo)航條跳轉(zhuǎn)路由樣式控制
 },
 mutations: {
 //控制專業(yè)介紹詳情顯示隱藏
 updatemajorDetail(state, majorDetail) {
  state.majorDetail = majorDetail;
 },
 updateIndex(state, Index) {
  state.Index = Index;
 }
 }
});

效果圖:

現(xiàn)在在這個(gè)頁面里點(diǎn)擊了解更多的時(shí)候跳轉(zhuǎn)到新聞資訊頁面,然后然后state里的值,然后改變當(dāng)前的url以及導(dǎo)航選中新聞資訊。

總結(jié)

以上所述是小編給大家介紹的vue使用vuex實(shí)現(xiàn)首頁導(dǎo)航切換不同路由的方法,希望對(duì)大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

最新評(píng)論

红安县| 冷水江市| 吉安市| 苗栗县| 都安| 香港| 涡阳县| 沁源县| 原阳县| 曲松县| 苏尼特右旗| 海南省| 夏河县| 舟山市| 寻乌县| 南川市| 荔浦县| 威远县| 平原县| 滨州市| 象山县| 建平县| 河曲县| 共和县| 洛宁县| 杨浦区| 绥德县| 托克逊县| 棋牌| 芒康县| 尉犁县| 通山县| 浦东新区| 紫阳县| 南木林县| 海丰县| 尼勒克县| 平原县| 新龙县| 泰宁县| 元阳县|