Home> Web Front-end> Vue.js> body text

How to implement page value transfer in vue.js

coldplay.xixi
Release: 2020-11-26 15:13:04
Original
2368 people have browsed it

Vue.js method to implement page value transfer: 1. Use query to transfer value, the code is [var name=this.$route.query.name]; 2. Use params to transfer value, the code is [params : {userlist: 'userlist' }].

How to implement page value transfer in vue.js

  • This method is suitable for all brands of computers

vue .js method to implement page value transfer:

1. Use query to pass value [visible in the address bar]

For example, jump from a.vue to b .vue, passname='jack', the code is as follows:

this.$router.push({ path: "/result", query: { name: 'jack' } });
Copy after login

Receive parameters in b.vue through the url in the address bar;

I created this When receiving in the function,var name=this.$route.query.name;can receive the name parameter;

2. Use params to pass the value [address The column is not visible】

One thing to note about this method is that you need to write the name in index.js under the router when making a request.

You can pass the value together with the query;

this.$router.push({ path: "/result", name: "Result", query: { name: 'name' }, params: { usersitelist: 'userlist' } });
Copy after login

The value passed by params is not visible in the address bar, but the value method is the same as query. I also get the value in the created function;

var usersitelist = this.$route.params.usersitelist;
Copy after login

Related free learning recommendations :javascript(Video)

The above is the detailed content of How to implement page value transfer in vue.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!