# 微信本地存储

小程序销毁会删除本地存储的信息。从后台返回进入小程序,信息不会被删除

// 异步存值
wx.setStorage({
	key: key,
	data: value,
});
// 同步存值
wx.setStorageSync(key, value);

// 同步获取
wx.getStorageSync(key);
// 异步取值
wx.getStorage({
	key: "key",
	success: (res) => {
		console.log(res.data);
	},
});

// 异步删除
wx.removeStorage({
	key: "key",
	success(res) {
		console.log(res);
	},
});
// 同步删除
wx.removeStorageSync("key");
上次更新: 10/29/2019, 6:04:16 PM