In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to define the scope of this in Mini Program development", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to define the this scope in Mini Program development".
This scope
When debugging, this may not report errors because of the definition, so it is very troublesome to debug, so we should pay special attention to it.
OnLoad: function () {var that = this wx.request ({url: 'https:// domain name / AppService/UserHandler.ashx', data: {}, method:' GET', header: {'Content-Type':' application/json'} Success: function (res) {that.setData ({})}, fail: function (res) {}})}
Async
Request is an asynchronous request, so the return value of a sibling function, a request and a get request cannot be obtained, so you need to use a callback function
TLS version
When requesting data, you will be prompted that a TLS version cannot be higher than 1.0. check "Development environment does not verify the request domain name and TLS version" in the project.
Https
Mini Program only supports https bound with domain name, and configure it in request of Mini Program management interface.
Global variable
-> definition
/ / app.jsApp ({onLaunch: function () {}, globalData: {userInfo: null}})
-> assignment
/ / index.js// gets the application instance var app = getApp () Page ({data: {userInfo: {})
-> get to use
/ / user.js// get application instance var app = getApp () Page ({/ / page initial data data: {userInfo: null}, onLoad: function () {this.setData ({userInfo: getApp (). GlobalData.userInfo,})}) so far, I believe you have a better understanding of "how to define this scope in Mini Program development". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.