Vue路由官網(wǎng):https://router.vuejs.org/zh-cn/路由特點:1.保存歷史狀態(tài)2.刷新保留當前頁面位置
路由實現(xiàn)原理:通過ajax,h5 history,js原生哈希算法
Vue路由用法:
? ? ? <router-link to="路由路徑" tag="自定義標簽">首頁</router-link>
? ? ? <router-view>首頁內(nèi)容展示視圖</router-view>
配置路由表:
? ? ? 先引入
? ? ? ? ? ? import Vue from 'vue'
? ? ? ? ? ? import Router from 'vue-router'
? ? ? ? ? ? Vue.use(Router);
? ? ? ? ? ? import組件名from '組件路徑'//引入組件
? ? ? ? ? ? const routes=[
? ? ? ? ? ? ? ? ? {path:'/',redirect:要跳轉(zhuǎn)的路徑},//默認打開路徑
? ? ? ? ? ? ? ? ? {path:'路由路徑2',component:觸發(fā)的組件名2},
? ? ? ? ? ? ? ? ? {path:'路由路徑3',component:觸發(fā)的組件名3},
? ? ? ? ? ? ? ? ? ........
? ? ? ? ? ? ? ? ? //二級路由配置
? ? ? ? ? ? ? ? ? {path:'路由路徑4',
? ? ? ? ? ? ? ? ? ?component:觸發(fā)的組件名4,
? ? ? ? ? ? ? ? ? ?children:[{path:'',compoent:組件名}]}
? ? ? ? ? ? ]
? ? ? ? ? ? export default new Router({
? ? ? ? ? ? ? ? ? routes:routes,
? ? ? ? ? ? ? ? ? linkActiveClass:"high"http://高亮顯示
? ? ? ? ? ? });