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

old
https://router.vuejs.org/api/#the-route-object
const User = {
  template: '...',
  watch: {
    '$route' (to, from) {
      // react to route changes...
    }
  }
}
new
https://router.vuejs.org/guide/advanced/navigation-guards.html
const User = {
  template: '...',
  beforeRouteUpdate (to, from, next) {
    // react to route changes...
    // don't forget to call next()
  }
}
history-mode
404
asterisk (*):
{
  // will match everything
  path: '*'
}
{
  // will match anything starting with `/user-`
  path: '/user-*'
}
*&pathMatch
// 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
https://router.vuejs.org/guide/essentials/history-mode.html

https://github.com/pillarjs/path-to-regexp#parameters
/user/:id !== /user:id
typo bug


本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/10953770.html
未经授权禁止转载,违者必究!

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号