Home  >  Article  >  Web Front-end  >  How to pass values ​​between vue.js pages

How to pass values ​​between vue.js pages

coldplay.xixi
coldplay.xixiOriginal
2020-11-19 10:33:293788browse

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' }
        });

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' }
        });

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;

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!

Statement:
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