成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

vue設(shè)置默認(rèn)首頁的操作

瀏覽:108日期:2022-12-09 10:14:00

在router.js設(shè)置如下:

index就是默認(rèn)頁面

const routes = [// 公司項目{ 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)頁面帶不同的頭部信息時容易出現(xiàn)問題

補(bǔ)充知識:vue-router默認(rèn)的首頁渲染設(shè)置

當(dāng)一個vue項目的頁面打開,總得有一個默認(rèn)的首頁組件自動出現(xiàn)

不能只是點(diǎn)擊首頁的跳轉(zhuǎn)才出現(xiàn)

這個默認(rèn)的打開路由配置需要在router.js中的 VueRouter 實例中,改變routes數(shù)組

const router = new VueRouter({ routes:[ { path:’/’, //redirect 是重新定向 redirect:’/home’ }, { path:’/home’, component:Home }]})

這樣設(shè)置之后,就將默認(rèn)的路由路徑設(shè)置為/home

以上這篇vue設(shè)置默認(rèn)首頁的操作就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章: