- 实现vue前端路由的两种方式:
- 改变location.hash
- history,pushState(obj,data,url)
- history.replaceState()
- history.go()
- history.back()
- history.forward()
- router-link是vue内置标签,它会被渲染成一个a标签
linkActiveClassn属性: 改变 router-link-active的名称
replace: 不留下历史记录
tag: 渲染成什么标签
- Router属性
const router = new Router({
mode: 'history',
linkActiveClass: 'active',
routes: [
{
path: '/',
redirect: '/home'
},
{
path: '/home',
name: 'home',
component: home,
children: [
{
path: "",
redirect: "news",
},
{
path: 'news',
name: 'homeNews',
component: homeNews
}
],
meta: {
title: '首页'
}
},
]
})