今天小编给大家分享一下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 >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中如何设置二级路由”这篇文章的所有内容,感谢各位的阅读!相信大家阅读完这篇文章都有很大的收获,小编每天都会为大家更新不同的知识,如果还想学习更多的知识,请关注创新互联行业资讯频道。
网页名称:vue中如何设置二级路由
分享路径:https://www.cdcxhl.com/article42/ihgehc.html
成都网站建设公司_创新互联,为您提供网站改版、网站制作、响应式网站、云服务器、微信公众号、营销型网站建设
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联