Detailed explanation of WeChat mini-app page transfer value, detailed explanation of mini-app

Source: Internet
Author: User

Detailed explanation of the value transfer on the applet page and detailed explanation of the Applet

Detailed description of passing values on the applet page

1. Cross-page value transfer.

1. Use the navigator label to pass a value or wx. navigator, such


Here, the good_id = 16 parameter is passed into the detail page, and accepted in the onload method of the detail page.


To upload multiple parameters, use the & Link



If you want to transmit arrays, dictionaries, and other complex types, you must first convert JSON. stringify () to a string for transmission.


Note: If the converted string contains "? "This symbol will only be passed "? "The previous string, I guess this problem may be caused by the routing processing in the applet "? "Sensitive?

Well, this is the first option to use Jump URLs with parameter values.

2. Use getCurrentPages (); to get all pages in the stack, and then write the data to the corresponding page.


Here, you can upload strings or arrays,


In this way, the address is passed and accepted.

Note: This method is suitable for transmitting values (that is, existing pages) to the backend, so that data can be found in the stack and actively written, and must be accepted in the onshow () method, because only the onshow () method is executed when the result is returned again.

3. Write data locally and retrieve wx. setStorage/wx. getStorage from different pages. Many methods are encapsulated in the applet to write local data. I will not talk about it here.



4. Declare the data as a global variable

Var detail = getApp (). detail; available on any page

2. Pass the value in the page

1. Set the id method to identify the parameter passed after the jump


Obtained in the bindtap-defined click method swiperTap: function (e);, var id = e. currentTarget. id;

2. Set the data-xxx method to identify the value to be passed


Note: The {index} in data-index = "{index}" is valid. When using wx-for to render the view layer, index indicates the subscript to be clicked. obtained in the bindtap-defined click method swiperTap: function (e);, that is, var index = e. currentTarget. dataset. index; this is also true for other parameters, var type = e. currentTarget. dataset. type;

3. form and input boxes



Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.