The basic implementation of Vue routing changes Summary [three ways]

This example tells the basic implementation of VUE routing. Share to everyone for reference, specifically:

VUE routing the use scenario is generally applied when the application is jumped to the sub-route when the parent routing is jumped. The transmission method can be divided into

Params

to query , and params pass parameters can be divided into parameters and no parameters in the URL and The way, this is the three ways of Vue routing. Params

Patropenic (display parameters)

Params

Patropenic (display parameters) can also be divided into a declarative and programming Two ways

1, the declaration

Router-link

This method is passed through

router-link
assembly to TO Attribute implementation, the parameter of this method can be a string path, or an object that describes the address. When using this method, you need a sub-routing to configure parameters in advance, for example:

// Sub-routing configuration {PATH: ‘/ child /: id’, Component : Child} // Parent Routing Components Enter Child Routing
     
2, programmed
this. $ Router.push

When using this mode, the same requirement is required to configure parameters in advance, for example:

// Sub-routing configuration { PATH: ‘/ child /: ID’, Component: Child} // Parent Route Programming Movement (generally triggered) this. $ ROuter.push ({PATH: ‘/ CHILD / $ {ID}’,})
 can be obtained by the following code can be obtained by the following code   
This. $ Route.Params.id
Method 2:

Params

Display parameters)
Params
 The parameters (non-display parameters) can also be divided into two ways of declaration and programming, and different ways, here is the alias of routing  Name  
1, a declaration

Router-link

This method is also passed through Router- The TO attribute of the link component is implemented, for example:

Entering Child Routing

2, programmatic this. $ router.push

this method allows traditional values ​​when the same parameters need to configure the sub-route in advance, but can not be used
: / ID  is transmitted, because the parent route has been used in  params , for example:  
// Sub-routing configuration {path: ‘/ child, name:’ child ‘, Component: Child} // Parent Route Programming Movement (generally triggered) this. $ Router.push ({name:’ child ‘, Params: {ID: 123}})

In the sub-routing, the passing parameter value

. route.params.id

Note: this use of the above
 params  does not display url parameter passing mode result in a page refresh time, transfer Visit  
Method 3: Query
Transceiver (display parameter)

Query Transfer (display parameter) can also be divided into a declarative and programming Two ways
  1, declaration  Router-link 

This method is also passed through Router-Link assembly to TO Attribute implementation, but when using this method, it is necessary to configure the routing alias (Name attribute) in advance, for example:


// Sub-routing configuration {PATH: ‘/ child, name:’ Child ‘, Component: Child} // Parent Routing Components

Entering Child Routing

2, programming
THIS. $ Router.push

When using this method, the same needs to be configured in advance of the routing alias (Name attribute), for example:

// Sub-routing configuration {path: ‘/ child, name:’ child ‘, component: child} // Parent Route Programming Module (generally triggered) this. $ ROUTER .PUSH ({Name: ‘Child’, Params: {ID: 123}})
   can be obtained by the following code can be obtained by the following code   
THIS. $ Route.query.id
It is desirable to help the Vue.js programmed in this article.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment