This article mainly introduces relevant information on the detailed explanation of value transfer on the WeChat mini program page. Friends who need it can refer to
Detailed explanation of value transfer on the WeChat mini program page
1. Pass values across pages.
1. Use the navigator tag to pass values or wx.navigator, such as
Here, pass the good_id=16 parameter into the detail page, and then accept it in the onload method of the detail page.
If you need to pass multiple parameters, use & link. But
If you want to transfer complex types such as arrays, dictionaries, etc., you must first use JSON.stringify() to convert Pass it as a string.
Note: If the converted string contains the symbol "?", only the string before "?" will be passed. I guess this problem may be that the routing processing inside the mini program is sensitive to this "?"
Okay, this is the first url that relies on jumping to pass values with parameters
2. Use getCurrentPages(); to get all the pages in the stack, and then write the data to the corresponding page
You can pass strings here, you can also pass arrays, etc. ,
In this way, the address is passed and accepted
Note: This method is suitable for passing values later (that is, already existing page), so that the data can be found in the stack and actively written, and it must be accepted in the onshow() method, because only the onshow() method will be executed when returning again.
3. Write locally, across pages After taking out wx.setStorage/wx.getStorage, etc., the applet encapsulates many methods for writing local data, each with its own emphasis, so I won’t go into details here
4. Declare the data as a global variable
var detail = getApp().detail; Can be obtained on any page
2. Passing values within the page
1. Set the id method to identify the parameters passed after the jump
Obtained from the click method swiperTap defined by bindtap: function(e);, var id = e.currentTarget.id;
2. Method of setting data-xxx To identify the value to be passed
Note: {{index}} in data-index="{{index}}" is valid. When using wx-for to render the view layer, index represents the subscript of the click. It is obtained in the click method swiperTap: function(e); defined by bindtap, that is, var index = e.currentTarget.dataset.index; The same is true for other parameters. , var type = e.currentTarget.dataset.type;
3 . form form and input input box
WeChat applet complete source code Download
2.Takeaway: Implement similar anchor function
3.WeChat alarm clock: Dialogue implementation
The above is the detailed content of Mini program development--page value transfer. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment