Basic knowledge points
Three important files: app.js, app.json, app.wxss
app.js 可以监听并处理小程序的生命周期函数、声明全局变量 app.json 小程序全局配置,在该文件中配置小程序由哪些页面组成、配置小程序窗口背景色、导航条样式、默认标题等
Note: Do not add any comments
Each page path + page name in the WeChat applet must be written in the pages attribute of app.json, and the first one in pages The page is the homepage of the mini program
Each mini program page consists of four different suffix files with the same name under the same path, such as: index.js, index.wxml, index.wxss, index.json
The file with .js suffix is a script file, the .json suffix is a configuration file, the .wxss suffix is a style sheet file, and the .wxml suffix is a page structure The file
index.js file can monitor and process page life cycle functions, obtain applet instances, declare and process data, respond to page interactive events, etc.
To facilitate developers to reduce configuration items, the four files describing the page must have the same path and file name
App
getApp() 获取当前App实例 getCurrentPages() 获取当前页面栈
Note Matters: The framework does not run in the browser, such as document, window, etc. cannot be used
onLaunch 生命周期函数--监听小程序初始化(全局只触发一次) onShow 生命周期函数--监听小程序显示 当小程序启动或从后台进入前台显示触发 onHide 生命周期函数--监听小程序隐藏 当小程序从前台进入后台会触发 onError 错误监听函数
When a script error occurs in the applet or the api call fails, it will be triggered with an error message
Development Users can add any function or data to the Object parameter value, and use this to access
Page
data 页面的初始数据 onLoad 生命周期函数--监听页面加载 onReady 生命周期函数--监听页面初次渲染完成 onShow 生命周期函数--监听页面显示 onHide 生命周期函数--监听页面隐藏 onUnload 生命周期函数--监听页面卸载 onPullDownRefresh 页面相关事件处理函数--监听用户下拉动作 onReachBottom 页面上拉触底事件处理函数 onShareAppMessage 用户点击右上角转发 onPageScroll 页面滚动触发事件处理函数
The above is the detailed content of Introduction to WeChat Mini Programs. 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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools
