vue設(shè)置默認(rèn)首頁的操作
在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)。
相關(guān)文章:
1. CSS代碼檢查工具stylelint的使用方法詳解2. JavaScript數(shù)據(jù)類型對函數(shù)式編程的影響示例解析3. 利用CSS3新特性創(chuàng)建透明邊框三角4. CSS3實例分享之多重背景的實現(xiàn)(Multiple backgrounds)5. div的offsetLeft與style.left區(qū)別6. 不要在HTML中濫用div7. html清除浮動的6種方法示例8. vue實現(xiàn)將自己網(wǎng)站(h5鏈接)分享到微信中形成小卡片的超詳細(xì)教程9. 詳解CSS偽元素的妙用單標(biāo)簽之美10. 使用css實現(xiàn)全兼容tooltip提示框
