微信小程序框架_vue使用vuex完成官网导航切换不同
摘要: vue应用vuex完成导航栏转换不一样路由器的方式 本文关键详细介绍了vue应用vuex完成导航栏转换不一样路由器的方式 ,十分非常好,具备一定的参照效仿使用价值,必须的朋友能够参...
li @click="checkNav()" 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=='#/syno凡科抠图is'}" router-link to="/syno凡科抠图is" 学校简介 /router-link /li li @click="checkNav()" v-bind:class="{'active':Index=='#/major'}" router-link to="/major" 专业介绍 /router-link /li li @click="checkNav()" v-bind:class="{'active':Index=='#/campus'}" router-link to="/campus" 校园风采 /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" 就业中心 /router-link /li li @click="checkNav()" v-bind:class="{'active':Index=='#/enlist'}" router-link to="/enlist" 在线报名 /router-link /li li @click="checkNav()" v-bind:class="{'active':Index=='#/contact'}" router-link to="/contact" 联系我们 /router-link /li /ul /div /div /nav
css:
/* 导航栏 */ .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,//导航条跳转路由样式控制 mutations: { //控制专业介绍详情显示隐藏 updatemajorDetail(state, majorDetail) { state.majorDetail = majorDetail; updateIndex(state, Index) { state.Index = Index; });
效果图:
现在在这个页面里点击了解更多的时候跳转到新闻资讯页面,然后然后state里的值,然后改变当前的url以及导航选中新闻资讯。
总结
以上所述是小编给大家介绍的vue使用vuex实现首页导航切换不同路由的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对凡科网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!