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è)面打開(kāi),總得有一個(gè)默認(rèn)的首頁(yè)組件自動(dòng)出現(xiàn)
不能只是點(diǎn)擊首頁(yè)的跳轉(zhuǎn)才出現(xiàn)
這個(gè)默認(rèn)的打開(kāi)路由配置需要在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)文章:
1. IDEA 2020.1.2 安裝教程附破解教程詳解2. 利用ajax+php實(shí)現(xiàn)商品價(jià)格計(jì)算3. Java利用TCP協(xié)議實(shí)現(xiàn)客戶端與服務(wù)器通信(附通信源碼)4. 使用AJAX(包含正則表達(dá)式)驗(yàn)證用戶登錄的步驟5. JS圖片懶加載庫(kù)VueLazyLoad詳解6. Java實(shí)現(xiàn)的迷宮游戲7. Python 解決火狐瀏覽器不彈出下載框直接下載的問(wèn)題8. django queryset相加和篩選教程9. Java PreparedStatement用法詳解10. Spring如何集成ibatis項(xiàng)目并實(shí)現(xiàn)dao層基類封裝

網(wǎng)公網(wǎng)安備