微信小程序怎么设置、获取、删除本地缓存

微信小程序不能设置cookie,可以用设置缓存的方式来模拟。
设置缓存:

wx.setStorageSync("username", "zhangsan");//设置一个值
wx.setStorageSync({
  username:"zhangsan",
  tel:"18827866531"
});//设置多个值

获取缓存:

wx.getStorageSync('username');//获取缓存

//删除单个缓存

wx.removeStorageSync('username');//删除单个缓存

//清空所有缓存

wx.clearStorageSync();//清空所有缓存

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: