vue設(shè)置默認(rèn)首頁(yè)的操作
在router.js設(shè)置如下:
index就是默認(rèn)頁(yè)面
const routes = [// 公司項(xiàng)目{ path: ’/’, redirect: ’/index’ },{path:’/index’,component:index},{path:’/example’,component:example,redirect:’/edetail’,children:[{path:’/edetail’,component:edetail}]},{path:’/login’,component:login}]
不使用在根目錄設(shè)置router的方法,跳轉(zhuǎn)頁(yè)面帶不同的頭部信息時(shí)容易出現(xiàn)問(wèn)題
補(bǔ)充知識(shí):vue-router默認(rèn)的首頁(yè)渲染設(shè)置
當(dāng)一個(gè)vue項(xiàng)目的頁(yè)面打開,總得有一個(gè)默認(rèn)的首頁(yè)組件自動(dòng)出現(xiàn)
不能只是點(diǎn)擊首頁(yè)的跳轉(zhuǎn)才出現(xiàn)
這個(gè)默認(rèn)的打開路由配置需要在router.js中的 VueRouter 實(shí)例中,改變r(jià)outes數(shù)組
const router = new VueRouter({ routes:[ { path:’/’, //redirect 是重新定向 redirect:’/home’ }, { path:’/home’, component:Home }]})
這樣設(shè)置之后,就將默認(rèn)的路由路徑設(shè)置為/home
以上這篇vue設(shè)置默認(rèn)首頁(yè)的操作就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
