Skip to main content
Version: 3.x

Taro.getAppBaseInfo()

获取微信APP基础信息

支持情况:

H5: 不支持 SDKVersion、host、version

参考文档

类型​

() => Result

参数​

Result​

参数类型必填说明
SDKVersionstring否客户端基础库版本
enableDebugboolean否是否已打开调试。可通过右上角菜单或 Taro.setEnableDebug 打开调试。
hostHost否当前小程序运行的宿主环境
languagestring是微信设置的语言
versionstring否微信版本号
themekeyof Theme否系统当前主题,取值为light或dark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏)

Theme​

系统主题合法值

参数说明
dark深色主题
light浅色主题

Host​

参数类型说明
appIdstring宿主 app 对应的 appId

示例代码​

const appBaseInfo = Taro.getAppBaseInfo()

console.log(appBaseInfo.SDKVersion)
console.log(appBaseInfo.enableDebug)
console.log(appBaseInfo.host)
console.log(appBaseInfo.language)
console.log(appBaseInfo.version)
console.log(appBaseInfo.theme)