# vue-router
# query
- when you use
push
or userouter-link
,
{ name: 'W', query: { id:'1234', age:'12' }}
{ path: '/W', query: { id:'1234', age:'12' }}
always
add topath
, bothpath
andname
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