天天看點

vue-router的簡單使用踩坑

Vue.use(Router)
export default new Router({
  mode:"hash",//hash history
  //hash路由帶#号 history不帶#用來與後端設定的路由比對一起使用的
  routes: [
   {
        path:"/",
        component:App//元件
        // components:{//使用具名視圖
        //     a:App
        // }
   },
   {
     path:"/a",
    component:B
   },
  //  {
  //    path:"/no",
  //    component:B
  //  },
   {
     path:"*",//必須放在最下面
     component:B,
    // rdeirect:"/no" 做重定向 建議使用history與後端伺服器設定結合 不然還是使用hash比對404頁面
   }
  ]
})