时间:2021-05-26
项目当中使用vue的时候一定会用到路由,并且二级路由甚至三集路由的需求都是刚需,当然,多级路由的配置方法和二级的是一样的,简单讲讲二级路由的配置吧。
首先把一级路由的结构准备好:
<router-link to="/discover"> <div @click="clickFind('发现')"> <span class="icon-find"></span> <p>发现</p> </div> </router-link> <router-link to="/todayStudy"> <div @click="clickStudy('今日学习')"> <span class="icon-todayStudy"></span> <p>今日学习</p> </div> </router-link> <router-link to="/listenAnyWhere"> <div @click="clickListen('随时听')"> <span class="icon-listenAny"></span> <p>随时听</p> </div> </router-link> <router-link to="/bought"> <div @click="clickBought('已购')"> <span class="icon-areadyBy"></span> <p>已购</p> </div> </router-link> <router-link to="/mine"> <div @click="clickMe"> <span class="icon-me"></span> <p>我</p> </div> </router-link> </div> <router-view></router-view>在main.js里引入模块,并配置路由:
import discover from './components/discover/discover.vue'; import todayStudy from './components/todayStudy/study.vue'; import listen from './components/listenAnyWhere/listen.vue'; import bought from './components/bought/bought.vue'; import mine from './components/mine/mine.vue'; const routes = [ { path: '/', redirect: '/discover' }, { path: '/discover', component: discover }, { path: '/todayStudy', component: todayStudy }, { path: '/listenAnyWhere', component: listen }, { path: '/bought', component: bought }, { path: '/mine', component: mine } ];先看效果
点击每天听本书后进入下一级
在main.js里设置二级路由
import thisMouth from './components/discover/detailEveryDay/thisMouth/thisMouth.vue'; import four from './components/discover/detailEveryDay/fourth/fourth.vue'; import three from './components/discover/detailEveryDay/three/third.vue'; import two from './components/discover/detailEveryDay/two/second.vue'; import one from './components/discover/detailEveryDay/one/first.vue'; import twel from './components/discover/detailEveryDay/twe/twel.vue'; import elev from './components/discover/detailEveryDay/elven/elev.vue'; const routes = [ { path: '/', redirect: '/discover' }, { path: '/discover', component: discover, <span style="color:#ff0000;">children: [ { path: '/', component: thisMouth }, { path: '/thisMouth', component: thisMouth }, { path: '/forthMouth', component: four }, { path: '/thirdMouth', component: three }, { path: '/secondMouth', component: two }, { path: '/firstMouth', component: one }, { path: '/elMouth', component: twel }, { path: '/twMouth', component: elev } ]</span> },在相应的路径下建立各个路由所需模块即可
以上这篇vue二级路由设置方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
第一层路由我写在app.vue里面。如图所示:footer.vue:二级路由是这样:index.js里面的配置:效果图:效果出来了,又出现新的问题,就是点击二级
Vue嵌套路由:实现效果(路由三层嵌套,点击一级tab显示二级tab效果,二级tab点击切换对应内容,不在tab区域里的内容,切换时不重复渲染):Demo访问时
过WAN口IP地址控制二级路由器本身,而无法直接控制二级路由器下的终端。因此需要在二级路由器界面对二级路由器下面的终端进行限制。LAN-LAN级联指从主路由器的
主路由下接二级路由,不能缓解主路由的压力;主路由接二级路由后数据包的总量是没有减少的,连接二级路由器只能解决DHCP服务不足的情况。 路由器(Router,又
怎么访问二级路由?路由器上还可以安装二级路由,想要用电脑访问二级路由,该怎么访问呢?下面我们就来看看详细的教程。1、打开路由器界面,输入用户密码登录路由器。2、