query and use params

This is the route: 

{
    path:'/city/:city',
    name:'City',
    component:City
  }
 
Using the following query and pass parameters are params
query:
  <router-link  :to="{name:'City',query:{city:cityName}}"  >
   But you can use the browser to warn [vue-router] missing param for named route "City": Expected "city" to be defined
    Means; [Vue router] Missing route named "city" parameter: should be defined "city"
  Reason: query access path is preferably used to access i.e. <Router-Link: to = "{ path: '/ City /: City' , Query: {City: cityName}}">
  Accept data:
     this.$route.query.city
  Browser performance path: / City /: = Guangzhou City City?
params:
  <router-link  :to="{path:'/city/:city',params:{city:cityName}}"  >
   At this point, the browser is no error or warning, but the argument did not pass over the browser performance  / city /: city
  So to use the name instead of the path <Router-Link: to = "{ name: 'City' , Query: {City: cityName}}">
  Accept data:
     this.$route.params.city
  Browser performance path: / City / Guangzhou
Summary: Query redistributed routes using a path   params using the name to import routes
 
 
 
 
  

Guess you like

Origin www.cnblogs.com/j190512/p/11566790.html