Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Arrow function in WeChat Mini Programs's Development

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

I would like to share with you how to use the arrow function in WeChat Mini Programs's development. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it!

The use of arrowhead function

When we call the API request to change the page data through the data returned by the request, we often use a temporary pointer to save the this pointer.

But if you use ES6's arrow function, you can avoid

Use temporary pointers

OnLoad: function (options) {let that = this / / Save temporary pointer wx.request ({url: url + 'GetCouponlist', method:' POST', header: {'Content-Type':' application/x-www-form-urlencoded'}, data: {}, success (res) {that.setData ({/ / use temporary pointer coupon_length:res.data.data.length})})

Use the ES6 arrow function () = > {}

Success: (res) = > {this.setData ({/ / at this time this is still pointing to onLoad coupon_length:res.data.data.length functions)} these are all the contents of this article entitled "how to use Arrow functions in WeChat Mini Programs's Development". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report