We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
文档中说了,很多返回的都说promise,可是.d.ts文件中还写的 void
uni-app 对部分 API 进行了 Promise 封装,返回数据的第一个参数是错误对象,第二个参数是返回数据。
详细策略如下:
异步的方法,如果不传入 success、fail、complete 等 callback 参数,将以 Promise 返回数据。例如:uni.getImageInfo() 异步的方法且有返回对象,如果希望获取返回对象,必须至少传入一项 success、fail、complete 等 callback 参数。例如:uni.connectSocket() 同步的方法(即以 sync 结束),不封装 Promise。例如:uni.getSystemInfoSync() 以 create 开头的方法,不封装 Promise。例如:uni.createMapContext() 以 manager 结束的方法,不封装 Promise。例如:uni.getBackgroundAudioManager()
The text was updated successfully, but these errors were encountered:
关于d.ts适配Promise返回
Sorry, something went wrong.
关于api 的 Promise 化类型提示。除 uni.request 有返回值、同步的方法(即以 sync 结束)、以 create 开头的方法、以 manager 结束的方法、返回 task 的 api 暂不处理外,其他可以升级 @dcloudio/[email protected] 试试看
uni.request 有返回值
同步的方法(即以 sync 结束)
以 create 开头的方法
以 manager 结束的方法
返回 task 的 api
部分 api promise 化提示已支持,后续进度请跟踪 #3009 查看
No branches or pull requests
文档中说了,很多返回的都说promise,可是.d.ts文件中还写的 void
uni-app 对部分 API 进行了 Promise 封装,返回数据的第一个参数是错误对象,第二个参数是返回数据。
详细策略如下:
异步的方法,如果不传入 success、fail、complete 等 callback 参数,将以 Promise 返回数据。例如:uni.getImageInfo()
异步的方法且有返回对象,如果希望获取返回对象,必须至少传入一项 success、fail、complete 等 callback 参数。例如:uni.connectSocket()
同步的方法(即以 sync 结束),不封装 Promise。例如:uni.getSystemInfoSync()
以 create 开头的方法,不封装 Promise。例如:uni.createMapContext()
以 manager 结束的方法,不封装 Promise。例如:uni.getBackgroundAudioManager()
The text was updated successfully, but these errors were encountered: