Vue --- this. $ Route and this. $ Router two objects

// Note: This component in this body, there is this $ route and this $ router..

. // this $ route is designed to obtain the parameters of the route;

. // this $ router is designed to achieve programmatic navigation;

// Note:.. This $ route and this $ router two objects

// this. $ Route is a route parameter object, all routing parameters, params, query all belong to him

// this. $ Router is a routing (navigation objects), with its ease of use js code that implements routing forward, backward, jump to a new url address

 

1. The simplest

Click on the event - @ the Click = "goDesc"

methods: {
  
   goDesc () {
     . This $ router.push ( "path / home / goodsdesc /" + parameter this.goodsinfo.id);
  }
}
 
  2. Home tbar Jump ---
Tag jump <router-link class = "" to = "Path / home"> </ router-link>
We need to configure routing router.js
 
3. router.js China configure routing time attributes to the component definition name
props to receive routing parameters // Enable
{Path: 'path / home / goodscomment /: id', component: file name GoodsComment, props: true, name: 'name defined goodscmt'}
 this.$router.push({
        name: "goodscmt",
        params: { id: this.goodsinfo.id }
      });
 

Guess you like

Origin www.cnblogs.com/fdxjava/p/11645704.html