10. vue-router routing named

Naming routing configuration rules

For more convenient route represents a path, you can play an alias to the routing rules, that is, "named route."

const router = new VueRouter ({
 routes: [
 {
    path: '/user/ :id',
    name: 'user',
    component: User
   }
  ]
})
<router-link :to="{ name: 'user', params: { id: 123 }}">User</router-link>
router.push({ name: 'user', params: { id: 123 })

Guess you like

Origin www.cnblogs.com/songsongblue/p/12079245.html