import Vue from 'vue'
import Router from 'vue-router'
/* import User from '../components/User'
import Home from '../components/Home'
import About from '../components/About' */
import VueRouter from 'vue-router'
const Home =() => import ('../components/Home')
const About =() => import ('../components/About')
const User =() => import ('../components/User')
const HomeNew =() => import ('../components/HomeNews')
const Homemessage =() => import ('../components/Homemessage')
Vue.use(Router)
export default new Router({
mode: 'history',
linkActiveClass:'active',
routes: [
{
path:'',
//redirect重定向
redirect:'/home'
},
{
path: '/home',
component: Home,
meta:{
title:'首页'
},
children:[
{
path:'',
//redirect重定向
redirect:'news'
},
{
path:'news',
component:HomeNew
},{
path:'message',
component:Homemessage
},
]
},
{
path: '/about',
component:About,
meta:{
title:'关于'
},
},
{
path:'/user/:userId',
component:User,
meta:{
title:'用户'
},
}
]
})
Router.beforeEach((to,from,next) => {
//从from跳转到to
document.title = to.matched[0].meta.title
console.log(to);
next()
})
刚接触vue路由不明白是哪里出现问题,求大佬指点