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
微信小程序
小程序基础库: 2.30.4 使用框架: Vue 3
直接调用:
const res = await Taro.getUserCryptoManager().getRandomValues({length:24}) // res 为 undefined
返回结果为undefined,但文档中描述为支持Promise调用
使用回调函数success可以获得结果,但ts类型推断缺失randomValues字段
Taro.getUserCryptoManager().getRandomValues({ length:24, success(res){ // ts报错 不存在randomValues //res.randomValues } })
通过await调用可以获得结果
获得undefined
👽 Taro v3.6.4 Taro CLI 3.6.4 environment info: System: OS: macOS 13.2 Shell: 5.8.1 - /bin/zsh Binaries: Node: 19.5.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.3.1 - /usr/local/bin/npm npmPackages: @tarojs/cli: 3.6.4 => 3.6.4 @tarojs/components: 3.6.4 => 3.6.4 @tarojs/helper: 3.6.4 => 3.6.4 @tarojs/plugin-framework-vue3: 3.6.4 => 3.6.4 @tarojs/plugin-html: 3.6.4 => 3.6.4 @tarojs/plugin-platform-alipay: 3.6.4 => 3.6.4 @tarojs/plugin-platform-h5: 3.6.4 => 3.6.4 @tarojs/plugin-platform-jd: 3.6.4 => 3.6.4 @tarojs/plugin-platform-qq: 3.6.4 => 3.6.4 @tarojs/plugin-platform-swan: 3.6.4 => 3.6.4 @tarojs/plugin-platform-tt: 3.6.4 => 3.6.4 @tarojs/plugin-platform-weapp: 3.6.4 => 3.6.4 @tarojs/runtime: 3.6.4 => 3.6.4 @tarojs/shared: 3.6.4 => 3.6.4 @tarojs/taro: 3.6.4 => 3.6.4 @tarojs/taro-loader: ^3.6.4 => 3.6.4 @tarojs/webpack5-runner: 3.6.4 => 3.6.4 babel-preset-taro: 3.6.4 => 3.6.4 eslint-config-taro: 3.6.4 => 3.6.4
The text was updated successfully, but these errors were encountered:
Taro 因为只劫持了第一层 api 的调用,因此目前暂时无法对上述 api Taro.xxxx.getRandomValues 进行 Promise 类型的调用。 看了一下微信小程序的文档,这个 api 也支持在第一层直接调用,因此如果确实需要 Promise 类型的调用,你可以将代码修改为:
// @ts-ignore const value = await Taro.getRandomValues({ length: 10 })
而类型报错是类型文件没有对齐小程序文档,目前存在两个类型问题:
这个会在下个版本修复,可以先通过 ts-ignore 的方式来解决报错。
Sorry, something went wrong.
No branches or pull requests
相关平台
微信小程序
小程序基础库: 2.30.4
使用框架: Vue 3
复现步骤
直接调用:
返回结果为undefined,但文档中描述为支持Promise调用
使用回调函数success可以获得结果,但ts类型推断缺失randomValues字段
期望结果
通过await调用可以获得结果
实际结果
获得undefined
环境信息
The text was updated successfully, but these errors were encountered: