


Detailed explanation of registration and preview of WeChat mini program development
Build a development environment
- Download the latest version of WeChat applet development tools: Download page
- Choose the version suitable for your system to install. Currently, windows32, windows64 and mac systems are supported
- After the installation is complete, open the WeChat web developer tool, and then use your mobile phone WeChat to scan the QR code to log in.
- Choose to add a project. You can see that to add a new mini program project, you need to fill in three parts: AppID, project name, and project directory.
Note that after filling in the information, the tool will check the option to create a quick start project in the current directory by default. We use the default Just fine, no need to change.
Configuring the Mini Program
In this section, we will introduce the configuration of the Mini Program. First, let's take a look at what the app.json file automatically generated by the project looks like.
pages: Defines which pages this applet consists of.
{ "pages":[ "pages/logs/logs", "pages/index/index" ], ... }
window: Defines the configuration information of the window. [td]
{ "tabBar": { "backgroundColor": "#fbfbfb", "borderStyle": "white", "selectedColor":"#50e3c2", "color": "#aaa", "list": [{ "pagePath": "pages/index/index", "text": "首页", "iconPath": "images/home.png", "selectedIconPath": "images/homeHL.png" },{ "pagePath": "pages/me/me", "text": "我", "iconPath": "images/me.png", "selectedIconPath": "images/meHL.png" }] } }
networkTimeout: Used to set the timeout for various network requests.
[td]
##The following code is only an example
{ "networkTimeout": { "request": 5000, "connectSocket": 5000, "uploadFile": 5000, "downloadFile": 5000 }, "debug": true }
debug
项目结构
pages
- xxx.js 将在下小节讲到,因为这里涉及到的内容比较多,需要单独列出一节来讲。
- xxx.json 和 app.json 类似,app.json是整个微信小程序的配置文件,而xxx.json是xxx这单个页面的配置文件。
{ "navigationBarTitleText": "查看启动日志" }
注意:json 文件中不能有任何注释,不然会报错。
- xxx.wxml can be regarded as a variant of html, which also has the syntax of xml.
- xxx.wxss can be regarded as css.
utils
app.js
app.json
app.wxss
页面生命周期
App({ onLaunch: function() { // Do something initial when launch. }, onShow: function() { // Do something when show. }, onHide: function() { // Do something when hide. }, globalData: 'I am global data' })
Page() 函数用来注册一个页面。接受一个 object 参数,其指定页面的初始数据、生命周期函数、事件处理函数等。
Page({ data: { text: "This is page data." }, onLoad: function(options) { // Do some initialize when page load. }, onReady: function() { // Do something when page ready. }, onShow: function() { // Do something when page show. }, onHide: function() { // Do something when page hide. }, onUnload: function() { // Do something when page close. }, onPullDownRefresh: function() { // Do something when pull down. }, onReachBottom: function() { // Do something when page reach bottom. }, // Event handler. viewTap: function() { this.setData({ text: 'Set some data for updating view.' }) }, customData: { hi: 'MINA' } })
The above is the detailed content of Detailed explanation of registration and preview of WeChat mini program development. 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

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

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

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.