vue & vue router & dynamic router

vue & vue router & dynamic router

https://router.vuejs.org/guide/essentials/dynamic-matching.html#reacting-to-params-changeshtml

oldvue

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

const User = {
  template: '...',
  watch: {
    '$route' (to, from) {
      // react to route changes...
    }
  }
}

newgit

https://router.vuejs.org/guide/advanced/navigation-guards.htmlgithub

const User = {
  template: '...',
  beforeRouteUpdate (to, from, next) {
    // react to route changes...
    // don't forget to call next()
  }
}

history-mode

404api

asterisk (*):

{
  // will match everything
  path: '*'
}
{
  // will match anything starting with `/user-`
  path: '/user-*'
}

* & pathMatchide

// 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-routeui

https://router.vuejs.org/guide/essentials/history-mode.htmlthis

https://github.com/pillarjs/path-to-regexp#parametersurl


/user/:id !== /user:id

typo bug

相關文章
相關標籤/搜索