Skip to content
New issue

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

[Bug] Taro.getEnvInfoSync() 不支持字节小程序 #13957

Closed
wenfangdu opened this issue Jun 5, 2023 · 8 comments · Fixed by #13959
Closed

[Bug] Taro.getEnvInfoSync() 不支持字节小程序 #13957

wenfangdu opened this issue Jun 5, 2023 · 8 comments · Fixed by #13959
Labels
F-vue3 Framework - Vue 3 T-tt Target - 编译到字节跳动小程序 V-3 Version - 3.x

Comments

@wenfangdu
Copy link
Contributor

wenfangdu commented Jun 5, 2023

相关平台

字节跳动小程序

复现仓库

https://github.com/wenfangdu/taro-nutui/tree/getEnvInfoSync
小程序基础库: 2.68.1.4
使用框架: Vue 3

复现步骤

  1. pnpm run dev:tt
  2. 点击按钮

对应的字节小程序 API:https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/api/open-interface/env-info/get-env-info-sync

期望结果

无报错

实际结果

image

环境信息

Taro CLI 3.6.6 environment info:
    System:
      OS: macOS 13.4
      Shell: 5.2.15 - /opt/homebrew/bin/bash
    Binaries:
      Node: 16.19.1 - ~/.nvm/versions/node/v16.19.1/bin/node
      Yarn: 1.22.19 - ~/Library/pnpm/yarn
      npm: 9.6.7 - ~/Library/pnpm/npm
    npmPackages:
      @tarojs/cli: 3.6.7 => 3.6.7 
      @tarojs/components: 3.6.7 => 3.6.7 
      @tarojs/helper: 3.6.7 => 3.6.7 
      @tarojs/plugin-framework-vue3: 3.6.7 => 3.6.7 
      @tarojs/plugin-html: 3.6.7 => 3.6.7 
      @tarojs/plugin-platform-alipay: 3.6.7 => 3.6.7 
      @tarojs/plugin-platform-h5: 3.6.7 => 3.6.7 
      @tarojs/plugin-platform-jd: 3.6.7 => 3.6.7 
      @tarojs/plugin-platform-qq: 3.6.7 => 3.6.7 
      @tarojs/plugin-platform-swan: 3.6.7 => 3.6.7 
      @tarojs/plugin-platform-tt: 3.6.7 => 3.6.7 
      @tarojs/plugin-platform-weapp: 3.6.7 => 3.6.7 
      @tarojs/runtime: 3.6.7 => 3.6.7 
      @tarojs/shared: 3.6.7 => 3.6.7 
      @tarojs/taro: 3.6.7 => 3.6.7 
      @tarojs/webpack5-runner: 3.6.7 => 3.6.7 
      babel-preset-taro: 3.6.7 => 3.6.7 
      eslint-config-taro: 3.6.7 => 3.6.7 
@taro-bot2 taro-bot2 bot added F-vue3 Framework - Vue 3 T-tt Target - 编译到字节跳动小程序 V-3 Version - 3.x labels Jun 5, 2023
@wenfangdu wenfangdu changed the title [Bug] Taro.getAccountInfoSync() 不支持字节小程序 [Bug] Taro.getAccountInfoSync() 不支持字节小程序 Jun 5, 2023
@TheKonka
Copy link
Member

TheKonka commented Jun 5, 2023

不是一个东西吧,首先,Taro.getAccountInfoSync() 在字节小程序里面对于的就是 tt.getAccountInfoSync() 而不是 tt.getEnvInfoSync(), 再者,你这个链接是小游戏的文档,不是小程序的文档

@wenfangdu
Copy link
Contributor Author

wenfangdu commented Jun 5, 2023

@TheKonka 抱歉,链接放错了,https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/api/open-interface/env-info/get-env-info-sync ,Taro 有类似 tt.getEnvInfoSync() 的方法嘛?

@wenfangdu
Copy link
Contributor Author

https://developer.open-douyin.com/forum/question/post/624d41af35567d58e53b64f0

没有 tt.getAccountInfoSync() 这个方法呢

@TheKonka
Copy link
Member

TheKonka commented Jun 5, 2023

代码里面直接用 tt.getEnvInfoSync() 或者 Taro.getEnvInfoSync() 调用应该都可以,有报错是typescript类型报错,不影响编译运行,欢迎提pr完善类型

@wenfangdu
Copy link
Contributor Author

@TheKonka tt.getEnvInfoSync() 是可以的,Taro.getEnvInfoSync() 返回的是一个一直 pending 的 Promise,明显是不对的,想尽可能用 Taro 的方法,少调平台的方法

@TheKonka
Copy link
Member

TheKonka commented Jun 5, 2023

这是因为 taro 把这个api Promise化了

'getEnvInfoSync',

把这一行删掉就行了

@wenfangdu
Copy link
Contributor Author

@TheKonka 对应的类型是在哪添加的呢,我也来加下

@TheKonka
Copy link
Member

TheKonka commented Jun 5, 2023

getAccountInfoSync

packages/taro/types/api

@wenfangdu wenfangdu changed the title [Bug] Taro.getAccountInfoSync() 不支持字节小程序 [Bug] Taro.getEnvInfoSync() 不支持字节小程序 Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue3 Framework - Vue 3 T-tt Target - 编译到字节跳动小程序 V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants