Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between query and params in front and rear?

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the difference between query and params in the front and back end". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the difference between query and params in the front and back end".

Parmas in vue routing

You can only use name here, not path, otherwise you will directly ignore the contents of params.

Then add it to the routes

{

Path:'/W/:id/:age'

Name:'W'

Component:W

}

The name here is consistent with the name in the router-link above

Url depends on how the path is written.

Note that the / w in path can be written as / hhhhh as well.

But!

/: id and /: age cannot be omitted and their names cannot be changed

If you don't write, you can jump the component on the first click.

And the passed id value can be obtained through this.$route.parmas.id, but if

Refresh the page, and the ID and age values passed will be lost.

From this, we can see that params is stricter than query.

Req.query and req.params in Node

In the backend, the axios request from the front end is accepted

So we ran into these two brothers again.

What kind of axios request corresponds to what kind of acceptance?

There is not only req.query,req.params, but also a req.body.

Boy, it's a mess.

Suppose the front end now sends a request to the back end using axios to send id value to request the back end data

Req.params

What if the id value is written directly into the url sent?

Axios.get (`/ api/ 1234`)

Does this form look familiar?

It is very similar to the url of params above.

Let's just do it in reverse.

Router.get ('/ api/:id',function (req,res) {

Console.log (req.params.id)

.

})

Thank you for your reading, the above is the content of "what is the difference between query and params in the front and back end". After the study of this article, I believe you have a deeper understanding of what is the difference between query and params in the front and back end, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report