当前位置:网站首页>The wechat applet optimizes the native request through the promise of ES6

The wechat applet optimizes the native request through the promise of ES6

2022-04-23 15:07:00 Ruirui junior

 

stay request New in folder index.js

In need of page Page to introduce , For example, my home page rotation map data

 

 

Code :index.js

export const request = (params) => {

 

    return new Promise((resolve,reject) => {

        wx.request({

            ...params,

            success:(result)=>{

                resolve(result)

            },

            fail:(err)=>{

                reject(err)

            }

        })

    })

}

 

版权声明
本文为[Ruirui junior]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231408339547.html