Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to transfer values from child pages to parent pages in WeChat Mini Programs

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces WeChat Mini Programs in how to achieve the child page to the parent page of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this WeChat Mini Programs article on how to transfer the value of the child page to the parent page. Let's take a look.

A detailed explanation of the example of WeChat Mini Programs's sub-page transmitting values to the parent page

The above picture is the edit payment page, and the bottom picture is the sub-page that opens after clicking the icon to select a friend on the edit payment page. At this time, when you click on a friend of the child page, you need to pass the friend's name back to the edit payment parent page.

The approach taken is:

Get and manipulate the target Page object directly from the page routing stack. In this way, the information of the current page routing stack is obtained by calling API: getCurrentPages () of Mini Program. The corresponding Page object is stored in this routing stack according to the routing order of the page. We can easily get the complete Page object of the page above, which makes it possible to directly call the properties and methods of the Page object.

The code of the selected friend page is as follows:

Var pages = getCurrentPages (); var currPage = pages [pages.length-1]; / / currently select friend page var prevPage = pages [pages.length-2] / / the last edit payment page / / directly call the setData () method of the previous page to save the data to the edit payment page to prevPage.setData ({name: currentfriend.name / / the currently selected friend name is assigned to the name temporary variable in the edit payment}) This is the end of the article on "how to transfer values from the child page to the parent page in WeChat Mini Programs". Thank you for your reading! I believe that everyone has a certain understanding of the knowledge of "how to transfer values from the child page to the parent page in WeChat Mini Programs". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report