Recently I am developing a WeChat applet application. I also started from scratch and sorted out the areas that needed attention during the development process.
this scope
This may not report an error because of the definition when debugging, which makes debugging very troublesome, so pay special attention to it
onLoad: function () { var that = this wx.request({ url: 'https://域名/AppService/UserHandler.ashx', data: { }, method: 'GET', header: { 'Content-Type': 'application/json' }, success: function (res) { that.setData({ }) }, fail: function (res) { } }) }
Asynchronous
request is an asynchronous request, so the return value of the same level function, a request, and a get request cannot be obtained. , you need to use the callback function
TLS version
When requesting data, you will be prompted that a TLS version cannot be higher than 1.0, put " "Development environment does not verify the requested domain name and TLS version" check
https
The mini program only supports https bound to the domain name, and in the mini program management interface request for configuration
Global variables
->Definition
//app.js App({ onLaunch: function () { }, globalData: { userInfo: null } })
->Assignment
//index.js //获取应用实例 var app = getApp() Page({ data: { userInfo: {} } })
->Get used
//user.js //获取应用实例 var app = getApp() Page({ // 页面初始数据 data: { userInfo: null }, onLoad: function () { this.setData({ userInfo: getApp().globalData.userInfo, }) } })
【Related recommendations】
1. Complete source code download of WeChat mini program
2. Chai Ge WeChat mini program application store source code
3. WeChat mini program demo: Yangtao
The above is the detailed content of Simple example code for small 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

Zend Studio 13.0.1
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

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

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
