vue設置默認首頁的操作
在router.js設置如下:
index就是默認頁面
const routes = [// 公司項目{ path: ’/’, redirect: ’/index’ },{path:’/index’,component:index},{path:’/example’,component:example,redirect:’/edetail’,children:[{path:’/edetail’,component:edetail}]},{path:’/login’,component:login}]
不使用在根目錄設置router的方法,跳轉頁面帶不同的頭部信息時容易出現(xiàn)問題
補充知識:vue-router默認的首頁渲染設置
當一個vue項目的頁面打開,總得有一個默認的首頁組件自動出現(xiàn)
不能只是點擊首頁的跳轉才出現(xiàn)
這個默認的打開路由配置需要在router.js中的 VueRouter 實例中,改變routes數(shù)組
const router = new VueRouter({ routes:[ { path:’/’, //redirect 是重新定向 redirect:’/home’ }, { path:’/home’, component:Home }]})
這樣設置之后,就將默認的路由路徑設置為/home
以上這篇vue設置默認首頁的操作就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。
相關文章:
1. ASP中常用的22個FSO文件操作函數(shù)整理2. 無線標記語言(WML)基礎之WMLScript 基礎第1/2頁3. ASP調用WebService轉化成JSON數(shù)據(jù),附json.min.asp4. .Net core 的熱插拔機制的深入探索及卸載問題求救指南5. SharePoint Server 2019新特性介紹6. html清除浮動的6種方法示例7. 讀大數(shù)據(jù)量的XML文件的讀取問題8. ASP.NET Core 5.0中的Host.CreateDefaultBuilder執(zhí)行過程解析9. React+umi+typeScript創(chuàng)建項目的過程10. Vue+elementUI下拉框自定義顏色選擇器方式
