In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Today, I would like to share with you the relevant knowledge points about how to use this and that in WeChat Mini Programs. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
In WeChat Mini Programs, after the wx.request ({}); method call succeeds or fails, it is sometimes necessary to obtain the page initialization data data. At this time, if you use this.data to obtain it, you will not get it, and the debugging page will also report undefiend. The reason is that in javascript, this represents the current object, and it will change as the context changes during the execution of the program. In the callback function of wx.request ({}), the object has changed, so it is no longer wx.request ({}); the method object and the data property no longer exist. The official solution is to make a copy of the current object, as follows:
Var that=this;// copies the this object to the temporary variable that
You can get the data by using that.data in the success callback function.
However, there is another way, which is also very special, to change the success callback function to a declaration, as follows:
Success: res = > {this.setData ({loadingHidden: true, hideCommitSuccessToast: false})}
In this way, this can be used directly, and data data can be obtained completely.
Give me another complete example:
Success: res = > {if (res.data.code! = 0) {/ / submission failed this.setData ({loadingHidden: true, hiddenTips: false, tipsContent: res.data.message})} else {/ / successful submission this.setData ({loadingHidden: true, hideCommitSuccessToast: false}) subBtn = false / / timing, disappear in 3 seconds setTimeout (() = > {this.setData ({hideCommitSuccessToast: true}) wx.navigateBack ({delta: 2});}, 2000);}} above is all the content of this article "how to use this and that in WeChat Mini Programs". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.