一、配置vue2路由
router/index.js
1 import Vue from 'vue' 2 import VueRouter from 'vue-router' 3 import MyHeader from '@/components/MyHeader.vue' 4 import MyMain from '@/components/MyMain.vue' 5 6 Vue.use(VueRouter) 7 const router = new VueRouter({ 8 routes:[ 9 {path:'/page01/:name',component:MyHeader}, 10 {path:'/page02',component:MyMain} 11 ] 12 }) 13 14 15 export default router
main.js
1 import Vue from 'vue' 2 import App from './App.vue' 3 import router from './router' 4 5 Vue.config.productionTip = false 6 7 8 9 new Vue({ 10 render: h => h(App), 11 router 12 }).$mount('#app')
二、路由传参数
标签:vue,学习,Vue,VueRouter,router,import,路由 From: https://www.cnblogs.com/zhang-dan/p/18430983