xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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

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



©xgqfrms 2012-2020

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


posted @ 2021-01-21 18:02  xgqfrms  阅读(91)  评论(1编辑  收藏  举报