首頁  >  文章  >  web前端  >  vue.js路由顯示設定的方法介紹

vue.js路由顯示設定的方法介紹

不言
不言原創
2018-08-23 16:30:261413瀏覽

這篇文章帶給大家的內容是關於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路由器的使用方法總結(附程式碼)

#

以上是vue.js路由顯示設定的方法介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn