当前位置:网站首页>After the applet wx.setstoragesync, sometimes it can't get data with getstoragesync
After the applet wx.setstoragesync, sometimes it can't get data with getstoragesync
2022-07-23 07:13:00 【Weirdo haha】
background :
I can't get the store number on the shopping cart page 
problem :
yes wx.getStorageSync It is caused by not getting a value .
Current implementation :
Yes, save it after obtaining it wx.setStorageSync("merchantNo", userStoreInfo.data.merchantNo),
Take it directly every time you use it merchantNo: wx.getStorageSync("merchantNo").
solve :
1、 Write it directly as asynchronous acquisition , When the value cannot be obtained, go to the background again ;2、 When it is put into the cache, it is also saved into the global variable , The value is taken from the global or cache , If you can't get the data at this time, you can ask for re assignment asynchronously .
async goAgain(e) {
let params_ = {
orderNo: e.currentTarget.dataset.orderNo,
// merchantNo: wx.getStorageSync("merchantNo")
merchantNo: await this.getMerchantNo()
}
console.log('params_', params_)
oneMoreOrder(params_).then(res => {
if (res.code == 0) {
NCart.initNum()
wx.switchTab({
url: "/pages/shopping/cart"
});
} else {
wx.showToast({
title: res.msg,
duration: 2000,
icon: "none"
})
}
})
},
async getMerchantNo () {
try {
let value = wx.getStorageSync('merchantNo')
if (value) {
return value
}
let userStoreInfo = await getUserMerchant()
return userStoreInfo.data.merchantNo
} catch (e) {
console.log('eeee', e)
}
},
Reference article :
Applet wx.setStorageSync after , In use getStorageSync Sometimes it is impossible to obtain data
Use wx.getStorageSync Can't get value why ?
Wechat applet - Set local cache and read ( Sync , asynchronous )
边栏推荐
- 【JDBC】报错Exception in thread “main”com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communica
- thinkphp URL_ Mode =0 specific usage of normal mode
- How to do if the control panel program cannot be uninstalled? Compulsory uninstallation software tutorial
- 常见运算符
- AWS使用EC2降低DeepRacer的训练成本DeepRacer-for-cloud的实践操作
- How to open the tutorial of administrator permission setting for computer administrator permission
- 局域网SDN技术硬核内幕 - 前传 CPU里面有什么?
- 实现OPC UA publish/subscribe单次发送
- 小黑leetcode之旅:100 相同的树
- How to quickly shut down the computer shut down command sharing
猜你喜欢

The ability to detect movement in vivo and build a safe and reliable payment level "face brushing" experience

Electromagnetic field and electromagnetic wave experiment 4. Be familiar with the application of CST Studio Software in the electromagnetic field
![[FAQ] common reasons and solutions for the failure of in app payment services to pull up the payment page](/img/9c/64553c1be85f2ee9baf1156d48c594.png)
[FAQ] common reasons and solutions for the failure of in app payment services to pull up the payment page

Realize the national standard gb28181 streaming media service solution

Scientific computing and Simulation - a brief introduction and application of the nonlinear least square problem of Gauss Newton method

CloudWeGo 在飞书管理后台平台化设计实践

Pikachu靶场-SQL注入-搜索型注入过关步骤

Kotlin learning quick start (8) - Delegation

Stability control and Simulation of double inverted pendulum system (matlab/simulink)

Combing the docking process between the integration base and the business system
随机推荐
网上申请炒股账户安全吗?
电脑显示器分辨率多少合适?各尺寸显示器最佳分辨率及不同壁纸的选择介绍
小米活期宝和余额宝哪个好?小米活期宝与阿里余额宝区别详细对比介绍
Huawei shengteng competition materials
AWS uses EC2 to reduce the training cost of deep Racer practical operation of deep racer for cloud
小马激活工具出现Cannot open file k:\OEMSF 的解决方法
AE常用表达式汇总「建议收藏」
小黑leetcode之旅:590. N 叉树的后序遍历
电脑一拖二显示器分辨率怎么调? 两个显示器设置不同分辨率的技巧
VsCode如何使用国内镜像秒下载
电脑屏幕变大了怎么还原 电脑屏幕显示缩放教程
电脑时间经常不准怎么办?设置自动更新校对电脑时间的教程
cpu温度多少正常 cpu长期100度会烧吗
How to embed the monitoring image into wechat official account for live broadcast
电脑如何获取administrator权限 电脑管理员权限设置教程
Shell脚本
Design of boiler drum temperature control system (process control course design matlab/simulink)
Demo19- (to be updated)
W25Q128FV译文(二)
个性自定义财付通姓名 自定义财付通为马化腾等任意名字图解