Vue-router

-- 注册
-- let url = [
{
path: "/",
name: "home",
component: {
template: ``
}
}
]
-- let router = new VueRouter({
routes: url
})
-- const app = new Vue({
el: "#app",
router: router
})
-- <router-link to="/">首页</router-link>
-- <router-view></router-view>
-- 子路由
-- children: [
{}
]
-- 在父路由对应的组件的template里写router-link router-view

-- 命名路由
-- name
-- 注意to加冒号动态绑定
-- 路由参数
-- {
path: "/course/:id",
}
-- this.$route.params.id
-- this.$route.query.xxx
-- $route 是一个对象 存放当前路由的所有信息
-- $router VueRouter实例化对象
-- 手动路由
--this.$router.push("/")
--this.$router.push({name: "xxx"})
-- 重定向
-- redirect:{name: "xxx"}
-- 路由的钩子
-- beforeEach
-- to
-- from
-- next
-- afterEach
-- to
-- from

posted @ 2018-11-15 21:16  浮云遮月  阅读(103)  评论(0编辑  收藏  举报