您好,欢迎来到划拓汽车网。
搜索
您的当前位置:首页vue.js路由显示设置的方法介绍

vue.js路由显示设置的方法介绍

来源:划拓汽车网


本篇文章给大家带来的内容是关于vue.js路由显示设置的方法介绍,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

①设置 path 为 ‘/’

const router= new VueRouter({
 routes:[
 {path:'/',name:'home',component:Home}, //页面第一显示的组件
 {path:'/menu',name:'menu',component:Menu},
 {path:'*',redirect:'/'}
 ],
 mode:"history"
});

②设置 redirect 的值(适用于 二级路由)

const router= new VueRouter({
 routes:[
 {path:'/',name:'home',component:Home},
 {path:'/about',name:'about',component:About,redirect:{name:'contactLink'},children:[ //二级路由
 {path:'/about/contact',name:'contactLink',component:Contact},
 {path:'/history',name:'historyLink',component:History},
 ]},
 {path:'*',redirect:'/'}
 ],
 mode:"history"
});

相关推荐:

vue.js中二级路由和三级路由的代码解析

Vue.js路由器的使用方法总结(附代码)

Copyright © 2019- huatuoask.net 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务