vue中怎么设置二级路由-创新互联
本篇文章为大家展示了vue中怎么设置二级路由,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
创新互联公司-成都网站建设公司,专注成都做网站、成都网站设计、网站营销推广,主机域名,虚拟空间,网站运营有关企业网站制作方案、改版、费用等问题,请联系创新互联公司。首先把一级路由的结构准备好:
发现
今日学习
随时听
已购
我
在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,
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
}
]
},
在相应的路径下建立各个路由所需模块即可
上述内容就是vue中怎么设置二级路由,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联成都网站设计公司行业资讯频道。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
本文标题:vue中怎么设置二级路由-创新互联
网站URL:http://lswzjz.com/article/eheig.html