This article mainly introduces the detailed explanation and simple examples of onLoad in WeChat Mini Program. Friends in need can refer to
OnLoad in WeChat Mini Program
onLoad is a life cycle function, indicating page loading
onLoad has an Object type parameter by default, which refers to the query parameter called by other pages to open the current page
Give me an example~
When we have a click method onTap in the js script of the first page
When the page is clicked, the page jumps to the second page, use? The form of id = secondId passes a value to the second page (secondId here is a value that has already been obtained)
onTap: function(){ wx.navigateTo({ url: "second?id=" + secondId })
Then we go to second Receive this id in the js file
The parameter option here is the Object parameter we received before, so we can use this id value in second.js
Page({ onLoad: function(options){ var secondId = options.id; console.log(postId); } })
Note:
When I first started running this code, the postId output was always undefined, and the output There is no id value in option. Finally, the solution was solved by changing the url in first from single quotes to double quotes. I thought it was really the reason, but I changed it back to single quotes and found that it still runs normally. I don't know where the bug is, but I have encountered this situation several times where I have to change something insignificant to make it run normally.
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
WeChat Mini Program
Example of scroll-view implementing pull-up loading and pull-down refresh
The above is the detailed content of Analysis of onLoad in WeChat Mini Program. 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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version
SublimeText3 Linux latest version

Atom editor mac version download
The most popular open source editor

SublimeText3 Chinese version
Chinese version, very easy to use