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

How to pass values ​​between vue.js pages

coldplay.xixi
Release: 2020-11-30 16:50:21
Original
3789 people have browsed it

Methods for transferring values ​​between vue.js pages: 1. Use query to transfer values, the code is [query: { name: 'jack' }]; 2. Use params to transfer values, the code is [params: {userlist: 'userlist' }].

How to pass values ​​between vue.js pages

The operating environment of this tutorial: windows7 system, vue2.9 version, this method is suitable for all brands of computers.

Methods to transfer values ​​between vue.js pages:

1. Use query to transfer values. The address bar is visible

For example, jump from a.vue to b.vue, pass name='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 receive it in the created function, var name = this.$route.query.name;You can receive the name parameter;

2. Use params to pass value. The address bar 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 requesting.

Yes Pass the value together with 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 pass values ​​between vue.js pages. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template