{"id":1522,"date":"2023-03-25T15:04:02","date_gmt":"2023-03-25T07:04:02","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1522"},"modified":"2023-04-27T21:45:40","modified_gmt":"2023-04-27T13:45:40","slug":"wechat-mini-program-asynchronous-and-synchronous-access-to-local-cache-and-call-attention","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/wechat-mini-program-asynchronous-and-synchronous-access-to-local-cache-and-call-attention\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5f02\u6b65\u4e0e\u540c\u6b65\u83b7\u53d6\u672c\u5730\u7f13\u5b58\u53ca\u5176\u8c03\u7528\u6ce8\u610f"},"content":{"rendered":"<ul>\n<li>\u5f02\u6b65\u83b7\u53d6\u672c\u5730\u7f13\u5b58\uff0c\u4e0d\u80fd\u987a\u5e8f\u8c03\u7528\u7f13\u5b58\u6570\u636e\uff0c\u800c\u662f\u9700\u8981\u5728success\u95ed\u5305\u4e2d\u8c03\u7528\uff0c\u5426\u5219\u6570\u636e\u4e3aundefined<\/li>\n<li>\u540c\u6b65\u83b7\u53d6\u672c\u5730\u7f13\u5b58\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u7f13\u5b58\u6570\u636e<\/li>\n<\/ul>\n<p><!-- more --><\/p>\n<h2>\u5f02\u6b65\u83b7\u53d6\u672c\u5730\u7f13\u5b58<\/h2>\n<pre><code class=\"language-javascript\">var _this = this\n\/\/\u83b7\u53d6\u7f13\u5b58\nwx.getStorage({\n  key: &#039;user&#039;,\n  success: function (res) {\n    var user = res.data\n    console.log(&#039;user: &#039; + JSON.stringify(user))\n    _this.setData({\n      user: user\n    })\n  }\n})<\/code><\/pre>\n<h2>\u540c\u6b65\u83b7\u53d6\u672c\u5730\u7f13\u5b58<\/h2>\n<pre><code class=\"language-javascript\">try {\n  var user = wx.getStorageSync(&#039;user&#039;)\n  if (user) {\n    console.log(&#039;user: &#039; + JSON.stringify(user))\n  }\n} catch (e) {\n\n}\n\nthis.setData({\n  user: user\n})<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5f02\u6b65\u83b7\u53d6\u672c\u5730\u7f13\u5b58\uff0c\u4e0d\u80fd\u987a\u5e8f\u8c03\u7528\u7f13\u5b58\u6570\u636e\uff0c\u800c\u662f\u9700\u8981\u5728success\u95ed\u5305\u4e2d\u8c03\u7528\uff0c\u5426\u5219\u6570\u636e\u4e3aundefined \u540c\u6b65 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[],"class_list":["post-1522","post","type-post","status-publish","format-standard","hentry","category-wechat-mini-program"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1522"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1522\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}