# vue-router

# query

  • when you use push or use router-link,
{ name: 'W', query: { id:'1234', age:'12' }}
{ path: '/W', query: { id:'1234', age:'12' }}
  • always add to path, both path and name can be used to find your component
  • by name, key-value
{
  path: '/hhhhhhh', // everything is ok
  name: 'W',  // must `W` to match `name: W`
  component: W
}
your url looks like :
http://localhost:8080/#/hhhhhhh?id=1234&age=12

your router:
this.$route.query = { id:'1234', age:'12' }
  • by path, still key-value
{
  path: '/W', // must '/W' to match path 
  name: 'hhhhhhhh',  // everything is ok
  component: W
}
your url looks like :
url:http://localhost:8080/#/W?id=1234&age=12

# parmas

  • only name
{ name: 'W', params: { id:'1234',age:'12' }}
  • but can be used in dynamic router to match your compoents
{
      path:'/W/:id/:age',
      name:'W',
      component:W
}
your url looks like:
                          id   age
http://localhost:8080/#/W/1234/12
Last Updated: 2022/3/4 下午3:36:18