Vue history模式和hash模式
路由器默认工作模式为hash模式
//引入文件,该文件专门用于创建整个应用的路由器
import VueRouter from 'vue-router'
//引入组件
import About from '../components/Home'
import Home from '../components/About'
import Message from '../components/Message'
import Detail from '../components/Detail'
//创建并暴露一个路由器
export default new VueRouter({
mode:'hash', //也可以切换为history模式
routes: [{
name:'about',
path: '/about',
component: About
},
{
name:'home',
path: '/home',
component: Home,
children: [{
name:'message/:id/:title', //占位符
path: "message",
component: Message
}]
}
]
})