您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本文小编为大家详细介绍“vue下如何设置二级路由”,内容详细,步骤清晰,细节处理妥当,希望这篇“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下如何设置二级路由”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。