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

不言
不言 原创
2018-08-23 16:30:26 1151浏览

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

①设置 path 为 ‘/’

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

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

const router= new VueRouter({
  routes:[
    {path:'//m.sbmmt.com/m/',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:'//m.sbmmt.com/m/'}
  ],
  mode:"history"
});

相关推荐:

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

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

以上就是vue.js路由显示设置的方法介绍的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。