


Detailed explanation of vue router using jquery and params to pass parameters
This article mainly introduces the use and difference of vue router using query and params to pass parameters. The editor thinks it is quite good. Now I will share it with you and give you a reference. Let’s follow the editor to take a look, I hope it can help everyone.
Written in front:
Passing parameters is an operation that is often used on the front end. Many scenarios will require the parameters of the previous page. This article will introduce in detail what vue router is. How to transfer parameters, and some small details. Friends in need can make a reference. If you like it, you can like it or follow it. I hope it can help everyone.
How does Vue router pass parameters
What are params and query?
params:/router1/:id,/router1/123,/router1/789, the id here is called params
query:/router1?id=123,/router1?id=456 , the id here is called query.
Routing interface:
router.js:
Routing settings here, when you use the params method to pass parameters, you must add the parameter name after the route, and pass the parameters When , the parameter name should correspond to the parameter name set behind the route. Using the query method, there is no such restriction and you can use it directly in the jump.
Note: If you do not write parameters on the route, you can still pass it, but your parameters will not be displayed on the url, and when you jump to other pages Or the parameters will be lost when refreshing the page (as shown in the figure below), then http requests or other operations that rely on this parameter will fail.
Pay attention to the routing parameters above. The id parameter is set on the routing. I did not set id2 in the routing, so id2 disappeared after refreshing. In the project, we can never ask the user not to refresh.
Component 1:
<template> <p> </p> <h1 id="从这个路由传参到别的路由">从这个路由传参到别的路由</h1> <router-link> router-link跳转router1 </router-link> </template> <script> export default { name: 'app_page', data () { return { status:110, status2:120, status3:119 } }, } </script>
Programmatic navigation jump:
The above router-link transfer parameters, you can also use the programmatic navigation in the router document to jump and transfer ginseng.
this.$router.push({ name:'router1',params: { id: status ,id2: status3},query: { queryId: status2 }}); //编程跳转写在一个函数里面,通过click等方法来触发
The effect of these two parameter transfers is exactly the same. Programmatic navigation can be used to make judgment jumps, such as whether to authorize, log in, etc. Friends who don’t know much about this, You can skip this programmatic navigation and come back to it later.
Component 2:
<template> <p> </p> <h1 id="接收参数的路由">接收参数的路由</h1> <h1 id="params-id-route-params"> params.id:{{ $route.params }}</h1> <h1 id="query-status-route-query-queryId">query.status:{{ $route.query.queryId }}</h1> <keep-alive> <router-view></router-view> </keep-alive> </template>
Passing parameters is relatively simple. You can successfully pass them according to the usage method of the above component.
Tip: To obtain the parameters on the route, use $route, without r after it.
What is the difference between params passing parameters and query passing parameters:
1. Usage
Just now, query needs to be introduced with path, and params needs to be introduced with name. The introduction and receiving parameters are similar, namely this.$route.query.name and this.$route.params.name.
Note that when receiving parameters, it is already $route instead of $router! !
2. The
query displayed is more similar to the get parameters in our ajax, and the params is similar to the post. To put it simply, the former displays the parameters in the browser address bar. The latter does not display
query:
params:
3. Params is part of the route. Must have. Query is a parameter spliced after the url. It doesn't matter if it doesn't exist.
Once params is set in a route, params will be part of the route. If the route has params to pass parameters, but this parameter is not passed during the jump, the jump will fail or the page will have no content.
For example: Jump to /router1/:id
<router-link>正确</router-link> <router-link>错误</router-link>
4. You can pass parameters without setting params and query. When params is not set, refreshing the page or returning parameters will be lost. This point As mentioned above
Related recommendations:
Detailed introduction to the three keywords params, Ref, and out in C
#How to pass parameters from parent to child component in vue.js
Vue.js Implementation method of passing parameters from parent to child component
The above is the detailed content of Detailed explanation of vue router using jquery and params to pass parameters. For more information, please follow other related articles on the PHP Chinese website!

JavaScript core data types are consistent in browsers and Node.js, but are handled differently from the extra types. 1) The global object is window in the browser and global in Node.js. 2) Node.js' unique Buffer object, used to process binary data. 3) There are also differences in performance and time processing, and the code needs to be adjusted according to the environment.

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
