应用技术与研究

Promise在微信小程序登录中的应用

展开
  • 江苏联合职业技术学院徐州财经分院
周岚(1977-),女,江苏徐州人,硕士,副教授,研究方向为程序设计、软件开发、数据库。

网络出版日期: 2021-06-16

The Application of Promise in Wechat Applet Login

Expand
  • Xuzhou Finance and Economics Branch

Online published: 2021-06-16

摘要

在微信小程序登录过程中获取微信用户信息时需要进行多个有关联的异步请求操作获取用户加密信息然后对其解密并返回传统的异步回调嵌套方法造成程序可读性差程序执行性能低下Promise的出现解决了微信小程序获取微信用户信息时多个异步操作请求问题对异步请求功能划分更明确大大提高了程序的可读性并提供了良好的错误处理逻辑

本文引用格式

周岚 . Promise在微信小程序登录中的应用[J]. 电脑与电信, 2021 , 1(3) : 52 -55 . DOI: 1008-6609(2021)03-0052-04

Abstract

In the process of getting Wechat user information in the login process of Wechat applet, it is necessary to carry out a num-ber of related asynchronous request operations to obtain the user's encrypted information, and then decrypt and return it. The tradi-tional nested method of asynchronous callback results in poor program readability and low program execution performance. Theemergence of Promise solves the problem of multiple asynchronous operation requests when Wechat applet obtains Wechat user in-formation. It divides the asynchronous request function more clearly, greatly improves the readability of the program, and providesgood error handling logic.
Options
文章导航

/