Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the differences between query and params in vue

Shulou Source: shulou.com Published: 2022-06-01 05:11:36 10月28日 Update

Most people do not understand the knowledge points of this article "what are the differences between query and params in vue", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what is the difference between query and params in vue".

Differences: 1. Query writes the parameter address with path, while params uses name to write the parameter address; 2, the parameter does not disappear when query refreshes the page, but it disappears when params refreshes the page; 3. The parameter passed by query will be displayed in the url address bar, while the parameter passed by params will not be displayed in the address bar.

This article operating environment: windows10 system, Vue2.9.6 version, DELL G3 computer.

What is the difference between query and params in vue

Query syntax:

This.$router.push ({path: "address", query: {id: "123"}}); this is the pass parameter this.$route.query.id;, this is the accept parameter

Params syntax:

This.$router.push ({name: "address", params: {id: "123"}}); this is the pass parameter this.$route.params.id;, this is the accept parameter

Difference:

1. First of all, it is written differently. Query is written using path to write the parameter address, while params is written using name to write the parameter address. You can take a look at the relevant attributes when you write the route, or you can output the routing object information to take a look.

two。 The receiving method is different, one is received by query, the other is received by params. The summary is that who sends it and who receives it.

The parameters will not disappear when 3.query refreshes the page, but when params refreshes the page, the parameters will disappear. You can consider the local storage solution.

The parameters passed by 4.query are displayed in the url address bar, while the parameters passed by params are not displayed in the address bar.

The above is about the content of this article on "what is the difference between query and params in vue?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Parameters address content this is page writing that is time different article knowledge article grammar routing value information most objects properties methods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux OPPO Reno vpn MySQL