Home > WeChat Applet > Mini Program Development > Introduction to WeChat Mini Programs

Introduction to WeChat Mini Programs

一个新手
Release: 2017-09-20 09:10:40
Original
2409 people have browsed it

Basic knowledge points

Three important files: app.js, app.json, app.wxss

app.js     可以监听并处理小程序的生命周期函数、声明全局变量
app.json     小程序全局配置,在该文件中配置小程序由哪些页面组成、配置小程序窗口背景色、导航条样式、默认标题等
Copy after login

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()     获取当前页面栈
Copy after login

Note Matters: The framework does not run in the browser, such as document, window, etc. cannot be used

onLaunch     生命周期函数--监听小程序初始化(全局只触发一次)
onShow        生命周期函数--监听小程序显示
                         当小程序启动或从后台进入前台显示触发
onHide         生命周期函数--监听小程序隐藏
                         当小程序从前台进入后台会触发
onError        错误监听函数
Copy after login

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     页面滚动触发事件处理函数
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template