search
HomeWeChat AppletMini Program DevelopmentAnalysis of onLoad in WeChat Mini Program

Analysis of onLoad in WeChat Mini Program

Jun 23, 2018 pm 03:00 PM
AppletsWeChat applet

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

WeChat applet implements the method of dynamically setting placeholder prompt text and button selection/cancellation state

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

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

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use