{"id":28616,"date":"2024-11-25T14:58:36","date_gmt":"2024-11-25T06:58:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28616\/"},"modified":"2024-11-25T14:58:36","modified_gmt":"2024-11-25T06:58:36","slug":"%e6%80%bb%e7%bb%93%e6%9c%89%e5%85%b3%e5%b0%8f%e7%a8%8b%e5%ba%8f%e5%bc%80%e5%8f%91%e7%9a%84%e7%bb%8f%e9%aa%8c","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28616\/","title":{"rendered":"\u603b\u7ed3\u6709\u5173\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u7684\u7ecf\u9a8c"},"content":{"rendered":"<p><strong>\u5fae\u4fe1\u5c0f\u7a0b\u5e8f \u5f00\u53d1\u7ecf\u9a8c\u6574\u7406<\/strong><\/p>\n<p><strong>\u524d\u8a00\uff1a<\/strong><\/p>\n<p>\u6700\u8fd1\u5c0f\u7a0b\u5e8f\u51fa\u6765\u4e86\uff0c\u516c\u53f8\u4e5f\u8981\u6c42\u6211\u4eec\u5f00\u53d1\u4e00\u6b3e\u5c0f\u7a0b\u5e8f\u3002<\/p>\n<p>\u4e8e\u662f\uff0c\u5c31\u5f00\u59cb\u7740\u624b\u505a\u4e86\uff0c\u505a\u4e86\u5dee\u4e0d\u591a\u4e00\u5468\u5427\uff0c\u4e5f\u9047\u5230\u4e86\u5f88\u591a\u95ee\u9898\uff0c\u8fd9\u91cc\u5c31\u6765\u603b\u7ed3\u4e00\u4e0b\u3002\uff08\u4e3b\u8981\u662f\u4ece\u4e00\u4e2aAndroid\u5f00\u53d1\u8005\u7684\u89d2\u5ea6\u6765\u8ff0\u8bf4\u7684\uff0c\u53ef\u80fd\u6bd4\u8f83\u96f6\u788e\u7684\u4e00\u4e9b\u77e5\u8bc6\u70b9\u548c\u7ecf\u9a8c\uff0c\u5982\u679c\u5927\u5bb6\u8fd8\u6709\u8865\u5145\uff0c\u6b22\u8fce\uff09<\/p>\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n<p>1\uff1a\u4f20\u53c2\uff0c\u65b9\u6cd5\u5224\u65ad<\/p>\n<p>js\u4e2d \u65b9\u6cd5\u4e2d\u53ef\u4ee5\u4f20\u9012\u4e00\u4e2a\u65b9\u6cd5\u4f5c\u4e3a\u5f62\u53c2\uff0c\u5728java\u4e2d\u662f\u4e0d\u53ef\u4ee5\u7684\u3002\u6bd4\u5982start\u9879\u76ee\u4e2d\u7684<\/p>\n<pre>getUserInfo:function(cb){\r\n&nbsp;var&nbsp;that&nbsp;=&nbsp;this\r\n&nbsp;if(this.globalData.userInfo){\r\n&nbsp;&nbsp;typeof&nbsp;cb&nbsp;==&nbsp;\"function\"&nbsp;&amp;amp;&amp;amp;&nbsp;cb(this.globalData.userInfo)\r\n&nbsp;}else{\r\n&nbsp;&nbsp;\/\/\u8c03\u7528\u767b\u5f55\u63a5\u53e3\r\n&nbsp;&nbsp;wx.login({\r\n&nbsp;&nbsp;&nbsp;success:&nbsp;function&nbsp;()&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;wx.getUserInfo({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;success:&nbsp;function&nbsp;(res)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;that.globalData.userInfo&nbsp;=&nbsp;res.userInfo\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeof&nbsp;cb&nbsp;==&nbsp;\"function\"&nbsp;&amp;amp;&amp;amp;&nbsp;cb(that.globalData.userInfo)\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;})\r\n&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;})\r\n&nbsp;}\r\n},<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u91cc\u5c31\u662f\u4f20\u9012\u4e00\u4e2a\u5f62\u53c2\uff0ccb\u7684\u65b9\u6cd5\uff0c\u5e76\u4e14\u8fd9\u91cc\u8fd8\u6709\u4e00\u4e2a\u5f88\u5de7\u5999\u7684\u5224\u65ad\u65b9\u6cd5<\/p>\n<pre>typeof&nbsp;cb&nbsp;==&nbsp;\"function\"&nbsp;&amp;amp;&amp;amp;&nbsp;cb(that.globalData.userInfo)<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5229\u7528\u7684&amp;&amp;\u7684\u8fd0\u7b97\u89c4\u5f8b\uff0c\u9996\u5148\u5224\u65adcb\u662f\u4e0d\u662f\u4e00\u4e2a\u65b9\u6cd5\uff0c \u8fd9\u91cc\u7684==\u53ef\u4ee5\u4f5c\u4e3a\u7c7b\u578b\u662f\u5426\u76f8\u5f53\u7684\u5224\u65ad\uff0c\u7136\u540e\u5728&amp;&amp;\u4e2d\u5982\u679c\u524d\u9762\u7684\u4e0d\u6ee1\u8db3\uff0c\u540e\u9762\u7684\u5219\u4e0d\u4f1a\u6267\u884c\uff1b\u5982\u679c\u662fcb\u662f\u4e00\u4e2a\u65b9\u6cd5\uff0c\u8c03\u7528cb\u65b9\u6cd5\uff0c\u5e76\u4e14\u4f20\u5165success\u6210\u529f\u56de\u8c03\u7684userinfo\u53c2\u6570<\/p>\n<p>\u8fd8\u6709\u4e00\u70b9\uff0cif(this.globalData.userInfo) \u53ef\u4ee5\u4f5c\u4e3a\u662f\u5426\u4e3anull\u7684\u5224\u65ad\u6761\u4ef6\uff0c\u5728java\u4e2d\u4e0d\u53ef\u4ee5\u3002<\/p>\n<p>2\uff1alog\u6253\u5370<\/p>\n<p>log\u7684\u6253\u5370\uff0c\u5982\u679c\u76f4\u63a5\u6253\u5370\u201c\u201d+\u53d8\u91cf \u662f\u4e0d\u53ef\u4ee5\u7684\uff0c\u56e0\u4e3a\u4eba\u5bb6\u6ca1\u6709toString()\u65b9\u6cd5<\/p>\n<pre>X&nbsp;console.log(\"info\"+info);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6240\u4ee5\u53ea\u80fd\u5206\u5f00\u6253\u5370<\/p>\n<pre>console.log(\"info\");\r\nconsole.log(info);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>3: json\u53d6\u5bf9\u8c61<\/p>\n<p>json\u7684\u4f7f\u7528\uff0c\u53ef\u4ee5\u901a\u8fc7 json[&#8220;key&#8221;]\u6765\u53d6\u5176\u5b50\u5bf9\u8c61<\/p>\n<pre>person:&nbsp;{\r\n&nbsp;&nbsp;&nbsp;name:&nbsp;\"jafir\",\r\n&nbsp;&nbsp;&nbsp;age:&nbsp;\"11\",\r\n}\r\nvar&nbsp;name&nbsp;=&nbsp;person[\"name\"];\r\nvar&nbsp;age&nbsp;=&nbsp;person[\"age\"];<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    <\/p>\n<pre>info:&nbsp;{persons:[{name:\"123\",age:11},{name:\"jafir1\",age:12}]}\r\n\/\/\u5982\u679c\u6709\u6570\u7ec4&nbsp;\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\u83b7\u53d6\r\n&nbsp;console.log(that.data.info[\"persons\"][1].name)\r\n&nbsp;console.log(that.data.info[\"persons\"][1].age)<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>4\uff1a\u5b9a\u4e49boolean\u7c7b\u578b\u503c<\/p>\n<p>\u8981\u6ce8\u610f\u5982\u679c\u5728page\u7684data\u4e2d\u8981\u5b9a\u4e49\u4e00\u4e2aboolean\u7c7b\u578b\u7684\u503c\uff0c\u5fc5\u987b\u662f isSuccess : true\u800c\u4e0d\u662f isSuccess :&#8221;true&#8221;<\/p>\n<pre>if&nbsp;(this.data.isSccess)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;console.log(\"true\")\r\n&nbsp;&nbsp;}&nbsp;else&nbsp;{\r\n&nbsp;&nbsp;&nbsp;console.log(\"false\")\r\n&nbsp;&nbsp;}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u56e0\u4e3a\u5982\u679c\u662fisSucees : &#8220;true&#8221; ,\u7ed3\u679c\u4e3atrue\uff0c\u6ca1\u95ee\u9898\uff0c\u4f46\u662f\u5982\u679c\u662fisSucess:&#8221;false&#8221;\uff0c\u7ed3\u679c\u4f9d\u65e7\u4e3atrue\uff0c<\/p>\n<p>\u56e0\u4e3a\u8fd9\u91cc\u7684isSuccess\u4e0d\u662fboolean\uff0c\u800c\u662f\u4e00\u4e2a\u975e\u7a7a\u7c7b\u578b\uff0c\u65e2\u7136\u975e\u7a7a\uff0cif\u5c31\u662f\u4e3atrue<\/p>\n<p>\u5982\u679c\uff0c\u9ed8\u8ba4undefined\uff0cif\u5219\u4e3afalse<\/p>\n<p>5\uff1a\u4f7f\u7528&#8221;that&#8221;<\/p>\n<p>\u5efa\u8bae\u5728 page{}\u5916\u9762\u5b9a\u4e49\u4e00\u4e2athat\u53d8\u91cf\uff0c\u7136\u540e\u5728onLoad\u4e2d\u8d4b\u503c\u4e3athis\uff0c\u4ee5\u540e\u6240\u6709\u7684\u5730\u65b9\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528that,\u8fd9\u6837\u5c31\u907f\u514d\u6709\u4e9b\u5730\u65b9\uff0cthis\u5e76\u4e0d\u662f\u6307\u5411page\u7684\u4e0a\u4e0b\u6587\u5bf9\u8c61<\/p>\n<pre>\/\/\u4e0a\u4e0b\u6587\u5bf9\u8c61\r\nvar&nbsp;that;\r\npage({\r\n&nbsp;onLoad:&nbsp;function&nbsp;(options)&nbsp;{\r\n&nbsp;&nbsp;\/\/&nbsp;\u9875\u9762\u521d\u59cb\u5316&nbsp;options\u4e3a\u9875\u9762\u8df3\u8f6c\u6240\u5e26\u6765\u7684\u53c2\u6570\r\n&nbsp;&nbsp;that&nbsp;=&nbsp;this;\r\n&nbsp;}\r\n\r\n\r\n...\r\nthat.setData({\r\n&nbsp;&nbsp;&nbsp;&nbsp;xxx:&nbsp;xxx,\r\n&nbsp;&nbsp;&nbsp;})\r\n})<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>6:page\u7684\u751f\u547d\u5468\u671f\u65b9\u6cd5<\/p>\n<ol>\n  <\/p>\n<li> <\/li>\n<li>\n<p>\u53ea\u6709onload\u4e2d\u6709options\u53c2\u6570\uff0c\u53ef\u4ee5\u83b7\u53d6\u9875\u9762\u4f20\u503c\u7b49\u7b49\uff0conload\u53ea\u4f1a\u6267\u884c\u4e00\u6b21<\/p>\n<\/li>\n<p> <\/p>\n<li> <\/li>\n<li>\n<p>\u4f46\u662fonShow\u53ef\u4ee5\u6bcf\u6b21\u5207\u6362\u9875\u9762\u7684\u65f6\u5019\u6267\u884c\uff0c\u6240\u4ee5\uff0c\u9700\u8981\u6bcf\u6b21\u5237\u65b0\u9875\u9762\u7684\u6570\u636e\u8bf7\u6c42\uff0c\u53ef\u4ee5\u653e\u5728onShow\u4e2d\uff0c\u6d4b\u8bd5\u8fc7\uff0c\u6027\u80fd\u4f53\u9a8c\u57fa\u672c\u65e0\u5f71\u54cd<\/p>\n<\/li>\n<p> <\/p>\n<li> <\/li>\n<li>\n<p>page\u7684\u751f\u547d\u5468\u671f\u6ca1\u6709Android\u90a3\u4e48\u4e30\u5bcc\uff0c\u9875\u9762\u4e4b\u95f4\u4f20\u503c\u4e5f\u6709\u4e00\u5b9a\u7684\u9650\u5236\u3002<\/p>\n<\/li>\n<p> <\/p>\n<li> <\/li>\n<li>\n<p>\u53ef\u4ee5\u901a\u8fc7\u666e\u901a\u7684url\u7684\u4f20\u503c\u65b9\u5f0f\u4f20\u503c\uff0cxxx?key = value \uff0c\u4f46\u662f\u8981\u6ce8\u610f\uff1a\u6211\u4eec\u4f20\u7684\u503c\u5176\u5b9e\u662f\u76f8\u5f53\u4e8e\u5b57\u7b26\u4e32\u548curl\u62fc\u63a5\u5728\u4e00\u8d77\uff0c\u8bf7\u4e0d\u8981\u76f4\u63a5\u4f20\u4e00\u4e2a\u5bf9\u8c61,\u56e0\u4e3a\u5bf9\u8c61\u6ca1\u6709toString\u65b9\u6cd5\u3002<\/p>\n<\/li>\n<p> \n<\/ol>\n<p>\u4f20\u9012json\u5bf9\u8c61\u7684\u6b65\u9aa4\u4e3a\uff1a<\/p>\n<p>1.\u628ajson\u5bf9\u8c61\u53d8\u6210\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u672c\u8eab\u5c31\u662f\u90a3\u5c31\u76f4\u63a5\u7528\uff0c\u5982\u679c\u662fjson\u5bf9\u8c61\uff0c\u9700\u8981 parseString(json)<\/p>\n<p>2.\u548curl\u8fdb\u884c\u53c2\u6570\u62fc\u63a5\uff1fkey=value<\/p>\n<p>3.\u53d6\u5f97\u65f6\u5019\u5728onload\u7684options\u91cc\u9762\u53d6\u51fa\uff0c<\/p>\n<pre>onLoad:&nbsp;function&nbsp;(options)&nbsp;{\r\nvar&nbsp;value=&nbsp;options.key\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7136\u540eJSON.stringify(value)\u8f6c\u4e3ajson\u5bf9\u8c61\u4f7f\u7528<\/p>\n<p>7: \u9875\u9762\u95f4\u8df3\u8f6c<\/p>\n<p>\u4ece\u4e3b\u9875\u8df3\u8f6c\u4e00\u4e2a\u65b0\u7684\u754c\u9762 \u65b0\u754c\u9762\u5904\u7406\u5b8c\u903b\u8f91 \u6210\u529f\u4e0e\u5426 \u7ed3\u675f\u4e4b\u540e\u600e\u4e48\u901a\u77e5 \u4e3b\u9875\u7ed3\u679c\uff1f<\/p>\n<p>\u8fd9\u79cd\u60c5\u51b5\uff0c\u4e00\u822c\u662f\u6ca1\u6709\u529e\u6cd5\u89e3\u51b3\u7684\u3002\u7ecf\u8fc7\u6d4b\u8bd5\uff0c\u5982\u679c\u4f60\u60f3\u8981\u4ece\u4e8c\u7ea7\u975e\u4e3b\u9875\u754c\u9762\u76f4\u63a5navigator\u6253\u5f00\u4e3b\u9875\uff0c\u662f\u4e0d\u884c\u7684\uff0c\u4f1a\u62a5\u9519\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u4eec\u91c7\u7528\u7684\u7b56\u7565\u662f\uff1a\u4e8c\u7ea7\u754c\u9762\u5904\u7406\u5b8c\u6570\u636e\u4e4b\u540e\uff0c\u76f4\u63a5\u8fd4\u56de\uff0c\u7136\u540e\u5728\u4e3b\u9875\u754c\u9762\u91cd\u65b0\u62c9\u53d6\u6570\u636e\u3002\u6240\u4ee5\u4f1a\u51fa\u73b0\uff0c\u6211\u4eec\u7684\u8bf7\u6c42\u63a5\u53e3\u662f\u5728onShow\u65b9\u6cd5\u91cc\u9762\u6267\u884c\u7684\u3002\u56e0\u4e3aonload\u53ea\u4f1a\u6267\u884c\u4e00\u6b21<\/p>\n<p>8\uff1awxml<\/p>\n<p>1.text\u6807\u7b7e\u53ef\u4ee5\u4f7f\u7528bindtap<\/p>\n<pre>&lt;image&gt;&lt;\/image&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u6765\u663e\u793a\u9ed8\u8ba4\u7684\u56fe\u7247<\/p>\n<p>3.\u518d\u5f3a\u8c03\u4e00\u4e0b \u5728\u6807\u7b7e\u4e2d\u4f7f\u7528data-xx-oo =&#8221;value&#8221;,\u5728\u5bf9\u5e94\u5bf9\u8c61\u4e2d\u53ef\u4ee5\u901a\u8fc7e.currentTarget.dataset.xxOo\u83b7\u5f97\uff0c\u8fd9\u91cc\u7684xx-oo \uff0c-<strong>\u5176\u5b9e\u662f\u4f1a\u8f6c\u4e49\u9a7c\u5cf0\u3002<\/strong>\u8fd9\u79cd\u4e00\u822c\u4f7f\u7528\u573a\u666f\u4e3a \u4f60\u53ef\u4ee5\u7ed9\u4f60\u6240\u70b9\u51fb\u6216\u8005\u7ed1\u5b9a\u4e8b\u4ef6\u7684view\u8bbe\u7f6e\u4e00\u4e2a\u6570\u636e\uff0c\u6bd4\u5982\u4f60\u4e00\u4e2apicker\u91cc\u9762\u67095\u4e2aview,\u5c31\u53ef\u4ee5<strong>\u7ed1\u5b9a\u6bcf\u4e2aview\u4e0d\u540c\u7684\u503c\uff0c\u5728\u89e6\u53d1\u4e8b\u4ef6\u7684\u65f6\u5019\u53d6\u5230\u76f8\u5e94\u7684\u503c<\/strong><\/p>\n<p>4.\u5982\u679c\u4f60\u60f3\u8981\u663e\u9690view\u4f60\u53ef\u4ee5\u901a\u8fc7wx:if=&#8221;true\/false&#8221;\u6765\u5904\u7406\uff0c\u4f46\u662f\u8fd9\u6837\u7684\u8bdd\uff0c\u5982\u679c\u4e3afalse\uff0cpage\u4e0d\u4f1a\u53bb\u6e32\u67d3\u8fd9\u4e2aview,\u5b83\u6240\u5728\u7684\u4f4d\u7f6e\u7a7a\u95f4\u4e5f\u4e0d\u4f1a\u9884\u7559\uff0c\u5047\u5982\u4e0b\u9762\u7684view\u5c31\u4f1a\u5f80\u4e0a\u6392\u3002\u5982\u679c\u60f3\u8981\u7559\u5b58\u5b83\u7684\u4f4d\u7f6e\u7a7a\u95f4\uff0c\u53ef\u4ee5\u4fee\u6539\u5176style\u6837\u5f0f\u6765\u89e3\u51b3<\/p>\n<pre>style=\"visibility:pw_isShow?'visible':'hidden'\"<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>9:\u7edf\u4e00\u7f51\u7edc\u8bf7\u6c42\u5904\u7406\u7ed3\u679c<\/p>\n<p>\u4f60\u53ef\u4ee5\u5c01\u88c5\u4e00\u4e0b\u7f51\u7edc\u8bf7\u6c42\u7684\u8fd4\u56de\u7ed3\u679c\uff0c\u505a\u7edf\u4e00\u5904\u7406<\/p>\n<pre>requestWithGet:&nbsp;function(paramsData)&nbsp;{\r\n&nbsp;data.method&nbsp;=&nbsp;'GET'\r\n&nbsp;this.requestInternal(paramsData)\r\n},\r\nrequestWithPost:&nbsp;function(paramsData)&nbsp;{\r\n&nbsp;data.method&nbsp;=&nbsp;'POST'\r\n&nbsp;this.requestInternal(paramsData)\r\n},\r\nrequestInternal:&nbsp;function&nbsp;(paramsData)&nbsp;{\r\n&nbsp;var&nbsp;that&nbsp;=&nbsp;this;\r\n&nbsp;console.log('requestInternal:&nbsp;\u5f00\u59cb\u8bf7\u6c42\u63a5\u53e3['&nbsp;+&nbsp;paramsData.url&nbsp;+&nbsp;']');\r\n&nbsp;\/\/\u5f00\u59cb\u7f51\u7edc\u8bf7\u6c42\r\n&nbsp;wx.request({\r\n&nbsp;&nbsp;url:&nbsp;paramsData.url,\r\n&nbsp;&nbsp;data:&nbsp;paramsData.data,\r\n&nbsp;&nbsp;method:&nbsp;paramsData.method,\r\n&nbsp;&nbsp;success:&nbsp;function&nbsp;(res)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;console.log('requestInternal:&nbsp;\u63a5\u53e3\u8bf7\u6c42\u6210\u529f['&nbsp;+&nbsp;paramsData.url&nbsp;+&nbsp;']');\r\n&nbsp;&nbsp;&nbsp;paramsData.success(res);\r\n&nbsp;&nbsp;},\r\n&nbsp;&nbsp;fail:&nbsp;function&nbsp;(res)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;console.log('requestInternal:&nbsp;\u63a5\u53e3\u8bf7\u6c42\u5931\u8d25['&nbsp;+&nbsp;paramsData.url&nbsp;+&nbsp;']');\r\n&nbsp;&nbsp;&nbsp;console.log(res);\r\n&nbsp;&nbsp;&nbsp;\/\/\/\/\u5728\u8fd9\u91cc\u505a\u8bf7\u6c42\u5931\u8d25\u7684\u7edf\u4e00\u5904\u7406\r\n&nbsp;&nbsp;&nbsp;wx.showToast({\r\n&nbsp;&nbsp;&nbsp;&nbsp;title:&nbsp;'\u7f51\u7edc\u8bbf\u95ee\u5931\u8d25',\r\n&nbsp;&nbsp;&nbsp;&nbsp;duration:&nbsp;1500\r\n&nbsp;&nbsp;&nbsp;})\r\n&nbsp;&nbsp;&nbsp;typeof&nbsp;paramsData.fail&nbsp;==&nbsp;\"function\"&nbsp;&amp;amp;&amp;amp;&nbsp;paramsData.fail(res);\r\n&nbsp;&nbsp;},\r\n&nbsp;&nbsp;complete:&nbsp;function&nbsp;(res)&nbsp;{\r\n\/\/\u5728\u8fd9\u91cc\u505a\u5b8c\u6210\u7684\u7edf\u4e00\u5904\u7406\r\n&nbsp;&nbsp;&nbsp;typeof&nbsp;paramsData.complete&nbsp;==&nbsp;\"function\"&nbsp;&amp;amp;&amp;amp;&nbsp;paramsData.complete(res);\r\n&nbsp;&nbsp;}\r\n&nbsp;})\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u6837\u5728\u4f7f\u7528\u8bf7\u6c42\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u76f4\u63a5\u5148wx.request({}) \u8fd9\u6837\uff0c\u5c31\u53ef\u4ee5IDE\u7ed9\u4f60\u8054\u60f3\u751f\u6210\u5bf9\u5e94\u7684\u8bf7\u6c42\u683c\u5f0f\uff0c\u7136\u540e\u76f4\u63a5\u628a\u201cwx.request\u201d \u66ff\u6362 \u201crequestWithGet\u201d\u6216\u8005\u201crequestWithPost\u201d\u5c31OK\u4e86<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u603b\u7ed3\u6709\u5173\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u7684\u7ecf\u9a8c\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fae\u4fe1\u5c0f\u7a0b\u5e8f \u5f00\u53d1\u7ecf\u9a8c\u6574\u7406 \u524d\u8a00\uff1a \u6700\u8fd1\u5c0f\u7a0b\u5e8f\u51fa\u6765\u4e86\uff0c\u516c\u53f8\u4e5f\u8981\u6c42\u6211\u4eec\u5f00\u53d1\u4e00\u6b3e\u5c0f\u7a0b\u5e8f\u3002 \u4e8e\u662f\uff0c\u5c31\u5f00\u59cb\u7740\u624b\u505a\u4e86\uff0c\u505a\u4e86\u5dee\u4e0d\u591a\u4e00\u5468\u5427\uff0c\u4e5f\u9047\u5230\u4e86\u5f88\u591a\u95ee\u9898\uff0c\u8fd9\u91cc\u5c31\u6765\u603b\u7ed3\u4e00\u4e0b\u3002\uff08\u4e3b\u8981\u662f\u4ece\u4e00\u4e2aAndroid\u5f00\u53d1\u8005\u7684\u89d2\u5ea6\u6765\u8ff0\u8bf4\u7684\uff0c\u53ef\u80fd\u6bd4\u8f83\u96f6\u788e\u7684\u4e00\u4e9b\u77e5\u8bc6\u70b9\u548c\u7ecf\u9a8c\uff0c\u5982\u679c\u5927\u5bb6\u8fd8\u6709\u8865\u5145\uff0c\u6b22\u8fce\uff09 \u603b\u7ed3 1\uff1a\u4f20\u53c2\uff0c\u65b9\u6cd5\u5224\u65ad js\u4e2d \u65b9\u6cd5\u4e2d\u53ef\u4ee5\u4f20\u9012\u4e00\u4e2a\u65b9\u6cd5\u4f5c\u4e3a\u5f62\u53c2\uff0c\u5728java\u4e2d\u662f\u4e0d\u53ef\u4ee5\u7684\u3002\u6bd4\u5982start\u9879\u76ee\u4e2d\u7684 getUserInfo:function(cb){ &nbsp;var&nbsp;that&nbsp;=&nbsp;this &nbsp;if(this.globalData.userInfo){ &nbsp;&nbsp;typeof&nbsp;cb&nbsp;==&nbsp;&#8220;function&#8221;&nbsp;&amp;amp;&amp;amp;&nbsp;cb(this.globalData.userInfo) &nbsp;}else{ &nbsp;&nbsp;\/\/\u8c03\u7528\u767b\u5f55\u63a5\u53e3 &nbsp;&nbsp;wx.login({ &nbsp;&nbsp;&nbsp;success:&nbsp;function&nbsp;()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;wx.getUserInfo({ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;success:&nbsp;function&nbsp;(res)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;that.globalData.userInfo&nbsp;=&nbsp;res.userInfo &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;typeof&nbsp;cb&nbsp;==&nbsp;&#8220;function&#8221;&nbsp;&amp;amp;&amp;amp;&nbsp;cb(that.globalData.userInfo) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;}) &nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;}) &nbsp;} }, \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u91cc\u5c31\u662f\u4f20\u9012\u4e00\u4e2a\u5f62\u53c2\uff0ccb\u7684\u65b9\u6cd5\uff0c\u5e76\u4e14\u8fd9\u91cc\u8fd8\u6709\u4e00\u4e2a\u5f88\u5de7\u5999\u7684\u5224\u65ad\u65b9\u6cd5 typeof&nbsp;cb&nbsp;==&nbsp;&#8220;function&#8221;&nbsp;&amp;amp;&amp;amp;&nbsp;cb(that.globalData.userInfo) \u767b\u5f55\u540e\u590d\u5236 \u5229\u7528\u7684&amp;&amp;\u7684\u8fd0\u7b97\u89c4\u5f8b\uff0c\u9996\u5148\u5224\u65adcb\u662f\u4e0d\u662f\u4e00\u4e2a\u65b9\u6cd5\uff0c \u8fd9\u91cc\u7684==\u53ef\u4ee5\u4f5c\u4e3a\u7c7b\u578b\u662f\u5426\u76f8\u5f53\u7684\u5224\u65ad\uff0c\u7136\u540e\u5728&amp;&amp;\u4e2d\u5982\u679c\u524d\u9762\u7684\u4e0d\u6ee1\u8db3\uff0c\u540e\u9762\u7684\u5219\u4e0d\u4f1a\u6267\u884c\uff1b\u5982\u679c\u662fcb\u662f\u4e00\u4e2a\u65b9\u6cd5\uff0c\u8c03\u7528cb\u65b9\u6cd5\uff0c\u5e76\u4e14\u4f20\u5165success\u6210\u529f\u56de\u8c03\u7684userinfo\u53c2\u6570 \u8fd8\u6709\u4e00\u70b9\uff0cif(this.globalData.userInfo) \u53ef\u4ee5\u4f5c\u4e3a\u662f\u5426\u4e3anull\u7684\u5224\u65ad\u6761\u4ef6\uff0c\u5728java\u4e2d\u4e0d\u53ef\u4ee5\u3002 2\uff1alog\u6253\u5370 log\u7684\u6253\u5370\uff0c\u5982\u679c\u76f4\u63a5\u6253\u5370\u201c\u201d+\u53d8\u91cf \u662f\u4e0d\u53ef\u4ee5\u7684\uff0c\u56e0\u4e3a\u4eba\u5bb6\u6ca1\u6709toString()\u65b9\u6cd5 X&nbsp;console.log(&#8220;info&#8221;+info); \u767b\u5f55\u540e\u590d\u5236 \u6240\u4ee5\u53ea\u80fd\u5206\u5f00\u6253\u5370 console.log(&#8220;info&#8221;); console.log(info); \u767b\u5f55\u540e\u590d\u5236 3: json\u53d6\u5bf9\u8c61 json\u7684\u4f7f\u7528\uff0c\u53ef\u4ee5\u901a\u8fc7 json[&#8220;key&#8221;]\u6765\u53d6\u5176\u5b50\u5bf9\u8c61 person:&nbsp;{ &nbsp;&nbsp;&nbsp;name:&nbsp;&#8220;jafir&#8221;, &nbsp;&nbsp;&nbsp;age:&nbsp;&#8220;11&#8221;, } var&nbsp;name&nbsp;=&nbsp;person[&#8220;name&#8221;]; var&nbsp;age&nbsp;=&nbsp;person[&#8220;age&#8221;]; \u767b\u5f55\u540e\u590d\u5236 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-28616","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=28616"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28616\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}