Skip to main content
Version: 3.x

Taro.getStorageSync(key)

Taro.getStorage 的同步版本

参考文档

类型#

(key: string) => any

参数#

参数类型说明
keystring本地缓存中指定的 key

示例代码#

Taro.getStorage({
key: 'key',
success: function (res) {
console.log(res.data)
}
})
try {
var value = Taro.getStorageSync('key')
if (value) {
// Do something with return value
}
} catch (e) {
// Do something when catch error
}

API 支持度#

API微信小程序H5React Native
Taro.getStorageSync✔️✔️