vue & this.$route & this.$router

时间:2023-03-09 04:06:28
vue & this.$route & this.$router

vue & this.\(route & this.\)router


const User = {
template: '<div>User</div>'
} const router = new VueRouter({
routes: [
// dynamic segments start with a colon
{ path: '/user/:id', component: User }
]
})

$route.query



$route.params



$route.query



$route.hash



https://router.vuejs.org/api/#the-route-object

vue & this.$route & this.$router

this.$route

读取

// Given a route { path: '/user-*' }
this.$router.push('/user-admin') this.$route.params.pathMatch // 'admin' // Given a route { path: '*' }
this.$router.push('/non-existing') this.$route.params.pathMatch // '/non-existing'

https://router.vuejs.org/guide/essentials/dynamic-matching.html#catch-all-404-not-found-route

this.$router

设置

// Given a route { path: '/user-*' }
this.$router.push('/user-admin') this.$route.params.pathMatch // 'admin' // Given a route { path: '*' }
this.$router.push('/non-existing') this.$route.params.pathMatch // '/non-existing'

https://router.vuejs.org/guide/essentials/dynamic-matching.html#catch-all-404-not-found-route

refs


vue & this.$route & this.$router

xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!