{"id":1312,"date":"2023-03-18T11:19:36","date_gmt":"2023-03-18T03:19:36","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1312"},"modified":"2023-04-29T09:13:34","modified_gmt":"2023-04-29T01:13:34","slug":"uni-app-complete-combat","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/uni-app-complete-combat\/","title":{"rendered":"uni-app\u5b8c\u6574\u5b9e\u6218"},"content":{"rendered":"<h2>\u80cc\u666f<\/h2>\n<p>\u5c0f\u7a0b\u5e8f\u5177\u6709\u8de8\u5e73\u53f0\u3001\u4f53\u9a8c\u597d\u3001\u9ad8\u7075\u6d3b\u6027\u4ee5\u53ca\u5373\u7528\u5373\u8d70\u3001\u65e0\u9700\u4e0b\u8f7d\u5b89\u88c5\u8bf8\u591a\u4f18\u52bf\u3002\u968f\u7740\u5fae\u4fe1\u56e2\u961f\u63a8\u51fa\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\uff0c\u56fd\u5185\u5404\u5927\u4e92\u8054\u7f51\u56e2\u961f\u4e5f\u76f8\u7ee7\u63a8\u51fa\u4e86\u5404\u81ea\u7684\u5c0f\u7a0b\u5e8f\uff0c\u624b\u673a\u5382\u5546\u4e5f\u8054\u5408\u63a8\u51fa\u4e86\u5feb\u5e94\u7528\u3002\u4f46\u7531\u4e8e\u5404\u79cd\u539f\u56e0\uff0c\u5404\u56e2\u961f\u7684\u5c0f\u7a0b\u5e8f\uff0c\u5e76\u6ca1\u6709\u5f62\u6210\u7edf\u4e00\u7684\u6807\u51c6\u6216\u8054\u76df\uff0c\u5bfc\u81f4\u90e8\u5206\u5e73\u53f0\u5dee\u5f02\u5316\u5927\uff0c\u8981\u5b9e\u73b0\u591a\u4e2a\u5e73\u53f0\u7684\u5c0f\u7a0b\u5e8f\u5c31\u5f97\u5199\u591a\u5957\u5c0f\u7a0b\u5e8f\u4ee3\u7801\uff0c\u8fd9\u7ed9\u5f00\u53d1\u8005\u548c\u4f01\u4e1a\u5e26\u6765\u4e0d\u5c11\u989d\u5916\u7684\u8d1f\u62c5\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a\u591a\u7aef\u7edf\u4e00\u7684\u89e3\u51b3\u65b9\u6848\u5c31\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002\u7edf\u4e00\u591a\u7aef\u6807\u51c6\u540e\uff0c\u8ba9\u4e00\u5904\u4ee3\u7801\uff0c\u591a\u5904\u8fd0\u884c\u6210\u4e3a\u4e86\u53ef\u80fd\u3002<\/p>\n<p><!-- more --><\/p>\n<h2>\u591a\u7aef\u6784\u5efa\u65b9\u6848\u9009\u578b<\/h2>\n<p>\u76ee\u524d\u591a\u7aef\u6784\u5efa\u6709\u4e0d\u5c11\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u901a\u5e38\u5728\u6280\u672f\u9009\u578b\u65b9\u9762\uff0c\u6211\u4eec\u4f1a\u8003\u8651\u4ee5\u4e0b\u51e0\u4e2a\u7ef4\u5ea6\uff1a<\/p>\n<ul>\n<li><strong>\u6846\u67b6\u7684\u751f\u6001\u53ca\u5176\u793e\u533a\u7684\u5927\u5c0f<\/strong><\/li>\n<li><strong>\u6846\u67b6\u7684\u6027\u80fd<\/strong><\/li>\n<li><strong>\u6846\u67b6\u7684\u5b66\u4e60\u6210\u672c\u4e0e\u5f00\u53d1\u6210\u672c<\/strong><\/li>\n<li><strong>\u6846\u67b6\u652f\u6301\u6784\u5efa\u7684\u5e94\u7528\u7aef\uff08\u5982\u662f\u5426\u652f\u6301\u5feb\u5e94\u7528\u548cQQ\u5c0f\u7a0b\u5e8f\uff09<\/strong><\/li>\n<li><strong>\u56e2\u961f\u7684\u6280\u672f\u6808\u7684\u5339\u914d\u7a0b\u5ea6<\/strong><\/li>\n<\/ul>\n<p>\u4ece\u793e\u533a\u4e0a\u7684\u5404\u79cd\u5b9e\u6218\u6848\u4f8b\u548c\u6d4b\u8bd5\u6848\u4f8b\u6765\u770b\uff0c\u76ee\u524d<code>Taro<\/code>\u548c<code>uni-app<\/code>\u662f\u76f8\u5bf9\u6bd4\u8f83\u6210\u719f\u3001\u5b8c\u5584\u7684\u591a\u7aef\u89e3\u51b3\u65b9\u6848\u3002<code>uni-app<\/code>\u4f5c\u4e3a\u56fd\u5185\u5c0f\u7a0b\u5e8f\u7684\u5f00\u521b\u8005\uff0c\u4e5f\u5236\u5b9a\u4e86\u4e00\u5957\u57fa\u4e8e<code>Vue.js<\/code>\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u5e76\u8dfb\u8eab\u524d\u5217\uff0c\u6210\u4e3a\u591a\u7aef\u6784\u5efa\u89e3\u51b3\u65b9\u6848\u7684\u4f18\u79c0\u8005\u4e4b\u4e00\u3002\u672c\u6587\u5c06\u5c31<code>uni-app<\/code>\u4f5c\u4e3a\u591a\u7aef\u65b9\u6848\uff0c\u8bb2\u89e3\u5982\u4f55\u4f7f\u7528<code>uni-app<\/code>\u591a\u7aef\u6784\u5efa\u6846\u67b6\u4e00\u6b65\u4e00\u6b65\u642d\u5efa\u4e00\u4e2a\u5b8c\u6574\u7684\u9879\u76ee\uff0c\u5e76\u5c31\u642d\u5efa\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u4e00\u4e9b\u95ee\u9898\u7ed9\u51fa\u4e00\u4e9b\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p>\u53c2\u8003\u5feb\u9012100\u5c0f\u7a0b\u5e8f\u7684\u6848\u4f8b\uff0c\u5feb\u9012100\u7b97\u662f\u56fd\u5185\u5c0f\u7a0b\u5e8f\u4e2d\u670d\u52a1\u7c7b\u5c0f\u7a0b\u5e8f\u4e00\u76f4\u6392\u540d\u9760\u524d\u7684\u5c0f\u7a0b\u5e8f\u4e86\uff0c\u5176\u76ee\u524d\u4e5f\u662f\u57fa\u4e8e<code>uni-app<\/code>\u5b9e\u73b0\u7684\u591a\u7aef\u7edf\u4e00\u7684\u5c0f\u7a0b\u5e8f\uff0c\u4ece\u6548\u679c\u6765\u770b\uff0c\u4f7f\u7528<code>uni-app<\/code>\u4f5c\u4e3a\u591a\u7aef\u7edf\u4e00\u7684\u65b9\u6848\uff0c\u4e0d\u4f1a\u6709\u5565\u5927\u7684\u95ee\u9898\u3002<\/p>\n<h2>\u9879\u76ee\u642d\u5efa<\/h2>\n<h3>\u521b\u5efa\u9879\u76ee<\/h3>\n<p><code>uni-app<\/code>\u652f\u6301\u901a\u8fc7 \u53ef\u89c6\u5316\u754c\u9762\u3001<code>vue-cli<\/code>\u547d\u4ee4\u884c \u4e24\u79cd\u65b9\u5f0f\u5feb\u901f\u521b\u5efa\u9879\u76ee\u3002\u672c\u6587\u5c06\u901a\u8fc7\u4ee5<code>HBuilderX<\/code>\u53ef\u89c6\u5316\u754c\u9762\u521b\u5efa\u9879\u76ee\u4e3a\u4f8b\uff0c\u4ece\u96f6\u5230\u4e00\u642d\u5efa\u8d77\u4e00\u4e2a\u5b8c\u6574\u7684\u9879\u76ee\u3002\u5b89\u88c5\u7684\u65b9\u6cd5\u8bf7\u67e5\u770b<code>uni-app<\/code>\u5b98\u7f51\u6587\u6863\u4e4b\u5feb\u901f\u4e0a\u624b<\/p>\n<p>\u4f7f\u7528<code>uni-app<\/code>\u5185\u7f6e\u7ec4\u4ef6\u6a21\u677f\u521b\u5efa\u540e\u7684\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u524d\u7aef\/uni-app\u9879\u76ee\u76ee\u5f55\u7ed3\u6784.png\" alt=\"uni-app\u9879\u76ee\u76ee\u5f55\u7ed3\u6784\" \/><\/p>\n<p>\u5404\u76ee\u5f55\u548c\u6587\u4ef6\u8bf4\u660e\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li><code>components<\/code>: \u516c\u5171\u7ec4\u4ef6\u76ee\u5f55\uff0c\u9ed8\u8ba4\u5185\u7f6e\u4e86<code>uni-app<\/code>\u7684\u5b98\u65b9\u6269\u5c55\u7ec4\u4ef6\uff0c\u5e94\u7528\u7684\u516c\u5171\u7ec4\u4ef6\u4e5f\u5c06\u653e\u7f6e\u5728\u8be5\u76ee\u5f55\u4e0b<\/li>\n<li><code>pages<\/code>\uff1a\u4e1a\u52a1\u9875\u9762\u76ee\u5f55\uff0c\u4e00\u4e2a\u9875\u9762\u5bf9\u5e94\u5c0f\u7a0b\u5e8f\u7684\u4e00\u4e2a\u9875\u9762\u8def\u7531<\/li>\n<li><code>static<\/code>: \u5b58\u653e\u5e94\u7528\u5f15\u7528\u9759\u6001\u8d44\u6e90\uff08\u5982\u56fe\u7247\u3001\u89c6\u9891\u7b49\uff09\u7684\u76ee\u5f55\uff0c\u9759\u6001\u8d44\u6e90\u53ea\u80fd\u5b58\u653e\u5728\u6b64\u76ee\u5f55\uff0c\u8be5\u76ee\u5f55\u4e0b\u7684\u5185\u5bb9\u4e0d\u4f1a\u7ecf\u8fc7\u7f16\u8bd1<\/li>\n<li><code>App.vue<\/code>: \u5168\u5c40\u5e94\u7528\u6587\u4ef6\uff0c\u7528\u4e8e\u914d\u7f6e\u5168\u5c40\u6837\u5f0f\u3001\u5168\u5c40\u751f\u547d\u94a9\u5b50\u7b49<\/li>\n<li><code>main.js<\/code>\uff1a\u5e94\u7528\u521d\u59cb\u5316\u6587\u4ef6\uff0c\u4e00\u822c\u5168\u5c40\u7684\u6269\u5c55\u5747\u5728\u8be5\u6587\u4ef6\u5b9e\u73b0<\/li>\n<li><code>mainfest.json<\/code>: \u5e94\u7528\u914d\u7f6e\u6587\u4ef6\uff0c\u4e3b\u8981\u5305\u542b\u5404\u4e2a\u5c0f\u7a0b\u5e8f\u7684appid\u3001\u7248\u672c\u53f7\u7b49\u4fe1\u606f<\/li>\n<li><code>pages.json<\/code>\uff1a\u8def\u7531\u914d\u7f6e\uff0c\u4e3b\u8981\u914d\u7f6e\u5e94\u7528\u7684\u9875\u9762\u8def\u7531\u3001\u5916\u89c2\u7b49<\/li>\n<li><code>uni.scss<\/code>\uff1a\u5168\u5c40\u7684scss\u53d8\u91cf\u6587\u4ef6\uff0c\u5728\u8be5\u6587\u4ef6\u5b9a\u4e49\u7684scss\u53d8\u91cf\u5168\u5c40\u53ef\u7528<\/li>\n<\/ul>\n<p>\u5b89\u88c5\u540e\u901a\u8fc7<code>HBuilderX<\/code>\u8fd0\u884c\u5230\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\uff08\u9700\u8981\u914d\u7f6e\u5fae\u4fe1\u5f00\u53d1\u8005\u5de5\u5177\u7684\u8def\u5f84\uff09\uff0c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u524d\u7aef\/uni-app\u5c0f\u7a0b\u5e8f\u8fd0\u884c\u6548\u679c.png\" alt=\"uni-app\u5c0f\u7a0b\u5e8f\u8fd0\u884c\u6548\u679c\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u4e00\u6b65\u4e00\u6b65\u6765\u5b8c\u5584\u6574\u4e2a\u5e94\u7528\u3002<\/p>\n<h3>\u81ea\u5b9a\u4e49\u5168\u5c40API<\/h3>\n<p>\u5728\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u91cd\u590d\u7684\u4f7f\u7528\u4e00\u4e9b\u65b9\u6cd5\uff0c\u5982http\u8bf7\u6c42\u76f8\u5173\u7684\u65b9\u6cd5\uff0c\u901a\u5e38\u6211\u4eec\u4f1a\u5c06\u8fd9\u4e9b\u65b9\u6cd5\u5c01\u88c5\u4e3a\u7edf\u4e00\u7684\u6a21\u5757\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u628a\u516c\u5171\u7684\u65b9\u6cd5\u7edf\u4e00\u653e\u5230\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684<code>utils<\/code>\u76ee\u5f55\u4e0b\u3002<\/p>\n<h4>\u53cd\u9988\u7c7bUI\u76f8\u5173API\u5c01\u88c5<\/h4>\n<p>\u7528\u6237\u64cd\u4f5c\u7684\u8fc7\u7a0b\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u4e00\u4e9b\u64cd\u4f5c\u53cd\u9988\uff0c\u5982<code>toast<\/code>\uff0c<code>modal<\/code>\u7b49\u3002\u4e0d\u540c\u7684\u5e94\u7528\u4e00\u822c\u90fd\u6709\u4e0d\u540c\u7684\u9ed8\u8ba4\u53cd\u9988\uff08\u5982\u6587\u6848\u3001\u5b57\u4f53\u989c\u8272\u7b49\uff09\uff0c\u6211\u4eec\u9996\u5148\u6765\u5c01\u88c5\u4e00\u4e0b\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u76f8\u5bf9\u6bd4\u8f83\u7b80\u5355\u3002<\/p>\n<p>\uff081\uff09<strong>toast &amp; modal<\/strong><\/p>\n<p>\u5728<code>utils<\/code>\u76ee\u5f55\u4e0b\u521b\u5efa<code>interactiveFeedback.js<\/code>\u6587\u4ef6<\/p>\n<p>\u7b2c\u4e00\u6b65\uff0c\u65b0\u5efa<code>showToast<\/code>\u548c<code>modal<\/code>\u65b9\u6cd5\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-javascript\">\/\/ toast\u53cd\u9988\nexport function showToast(content = &#039;&#039;, duration = 1500, icon = &#039;none&#039;) {\n  uni.showToast({\n    title: content,\n    icon: icon,\n    mask: true,\n    duration: duration\n  })\n}\n\n\/\/ \u5f39\u7a97\u53cd\u9988\nexport function modal(content = &#039;&#039;, opts = { showCancel: true }) {\n  return new Promise((resolve, reject) =&gt; {\n    uni.showModal({\n      title: opts.title || &#039;\u63d0\u793a&#039;,\n      content: content,\n      cancelText: (opts.cancelText || &#039;\u53d6\u6d88&#039;).slice(0, 4),\n      confirmText: (opts.confirmText ||  &#039;\u786e\u5b9a&#039;).slice(0, 4),\n      cancelColor: opts.cancelColor || &#039;#bebebe&#039;,\n      confirmColor: opts.confirmColor || &#039;#317ee7&#039;,\n      showCancel: opts.showCancel !== false,\n      success: res =&gt; {\n        if (res.confirm) {\n          resolve()\n        } else if (res.cancel) {\n          opts.handleCancel === true &amp;&amp; reject()\n        }\n      }\n    })\n  })\n}<\/code><\/pre>\n<p>\u5728\u5c0f\u7a0b\u5e8f\u4e2d\uff0c<code>confirmText<\/code>\u548c<code>cancelText<\/code>\u957f\u5ea6\u6700\u957f\u4e3a4\u4e2a\u5b57\u7b26\uff0c\u4ee5\u4e0a<code>modal<\/code>\u65b9\u6cd5\u9075\u5faa<code>promise<\/code>\u89c4\u8303<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff0c\u5b9a\u4e49<code>install<\/code>\u65b9\u6cd5<\/p>\n<pre><code class=\"language-javascript\">function install(Vue) {\n  Vue.prototype.$toast = showToast\n  Vue.prototype.$modal = modal\n}<\/code><\/pre>\n<p>\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u5b9a\u4e49\u66f4\u591a\u7684\u65b9\u6cd5\uff0c\u5982<code>loading<\/code>\uff0c<code>hideLoading<\/code>\u7b49<\/p>\n<p>\u7b2c\u4e09\u6b65\uff0c\u5bfc\u51fa\u76f8\u5173\u7684\u65b9\u6cd5<\/p>\n<pre><code class=\"language-javascript\">export default { install }<\/code><\/pre>\n<p>\u7b2c\u56db\u6b65\uff0c\u6253\u5f00<code>main.js<\/code>\u6587\u4ef6\uff0c\u5b89\u88c5\u6a21\u5757<\/p>\n<pre><code class=\"language-javascript\">import interactiveFeedback from &#039;@\/utils\/interactiveFeedback&#039;\n\nVue.use(interactiveFeedback)<\/code><\/pre>\n<p>\u5b89\u88c5\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7528\u4ee5\u4e0b\u7684\u65b9\u5f0f\u4f7f\u7528\uff1a<\/p>\n<pre><code class=\"language-javascript\">this.$toast(&quot;\u8fd9\u662f\u4e00\u4e2a\u5410\u53f8\u63d0\u793a&quot;)\nthis.$modal(&quot;\u8fd9\u91cc\u662f\u5f39\u7a97\u7684\u63d0\u9192\u5185\u5bb9&quot;, {\n    confirmText: &quot;\u6211\u77e5\u9053\u4e86&quot;,\n    handleCancel: true\n}).then(() =&gt; {\n    console.log(&quot;\u786e\u5b9a\u4e86&quot;)\n}).catch(() =&gt; {\n    console.log(&#039;\u53d6\u6d88\u4e86&#039;)\n})<\/code><\/pre>\n<h4>http\u8bf7\u6c42\u5c01\u88c5<\/h4>\n<p>http\u6a21\u5757\u4e13\u95e8\u7528\u6765\u505a\u63a5\u53e3\u8bf7\u6c42\uff0c\u901a\u5e38\u4e00\u4e2a\u5e94\u7528\u4e2d\u63a5\u53e3\u90fd\u4f1a\u6709\u516c\u5171\u7684\u53c2\u6570\u3001\u8bf7\u6c42\u5934\u3001\u6388\u6743\u4fe1\u606f\u7b49\uff0c\u5c06\u8fd9\u4e9b\u4fe1\u606f\u7edf\u4e00\u5c01\u88c5\u975e\u5e38\u6709\u5fc5\u8981\u3002\u7531\u4e8e\u9879\u76ee\u4e0a\u7ecf\u5e38\u8981\u7528\u5230\u4e00\u4e9b\u5e38\u91cf\u7b49\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u5148\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u521b\u5efa<code>config.js<\/code>\u6587\u4ef6\uff0c\u7528\u4e8e\u914d\u7f6e\u9879\u76ee\u4e0a\u4f7f\u7528\u7684\u4e00\u4e9b\u5e38\u91cf\uff08\u5982\u8bf7\u6c42\u8d85\u65f6\u3001\u63a5\u53e3\u670d\u52a1\u5668\u5730\u5740\u3001\u5c0f\u7a0b\u5e8f<code>appid<\/code>\u7b49)\uff0c\u8fd9\u91cc\u4e0d\u4e00\u4e00\u5217\u4e3e\uff0c\u53c2\u7167\u9879\u76ee\u6e90\u7801\u7684<code>config.js<\/code>\u6587\u4ef6\uff0c\u63a5\u7740\u5728<code>utils<\/code>\u76ee\u5f55\u4e0b\u521b\u5efa<code>request.js<\/code>\u6587\u4ef6<\/p>\n<p>\u7b2c\u4e00\u6b65\uff0c\u5f15\u5165\u5e38\u91cf\u548c\u5176\u4ed6\u516c\u5171\u65b9\u6cd5\u914d\u7f6e<\/p>\n<pre><code class=\"language-javascript\">import store from &#039;@\/store&#039;\nimport { showToast } from &#039;.\/interactiveFeedback.js&#039;\nimport {\n  API_BASE,\n  NETWORK_TIMEOUT,\n  DEFAULT_ERR_MESSAGE,\n  PLATFORM,\n  NETWORK_ERR_MESSAGE\n} from &#039;@\/config&#039;<\/code><\/pre>\n<p>\u7b2c\u4e8c\u6b65\uff0c\u5b9a\u4e49\u4e24\u4e2a\u6838\u5fc3\u5904\u7406\u65b9\u6cd5<\/p>\n<pre><code class=\"language-javascript\">\/**\n * \u57fa\u672c\u7684http\u8bf7\u6c42\n * @param {url: String} \u8bf7\u6c42\u7684\u94fe\u63a5\n * @param {opts.data: Object} \u8bf7\u6c42\u7684\u53c2\u6570\n * @param {opts.needAuth: Boolean } \u662f\u5426\u9700\u8981\u767b\u5f55\n * @param {opts.handleFail: Boolean} \u662f\u5426\u5904\u7406\u9519\u8bef\u4fe1\u606f\uff0c\u8bbe\u7f6e\u4e3afalse\u5c06\u5ffd\u7565\u8bf7\u6c42\u65f6\u7684\u9519\u8bef\n * @param {opts.accessToken: Boolean} \u662f\u5426\u5c06token\u8986\u76d6\u4e3a\u63d0\u4f9b\u5546token\n * *\/\nexport async function request(url, opts = {}) {\n  opts.data = opts.data || {}\n  if (opts.needAuth) {\n    const userinfo = await store.dispatch(&#039;user\/getUserInfo&#039;) \/\/ \u83b7\u53d6\u7528\u6237\u4fe1\u606f\n    opts.data.openid = store.getters.openid\n    opts.data.token = store.getters.token\n    opts.data.unionid = store.getters.unionid\n  }\n  return handleRequest(url, opts)\n}\n\n\/**\n * \u8bf7\u6c42\u5904\u7406\n*\/\nasync function handleRequest(url, opts, isUpload) {\n  opts.data.platform = PLATFORM.platform\n  opts.data.appId = PLATFORM.appid\n  let err = null\n  let res = null\n  if (isUpload) {\n    [err, res = {}] = await uni.uploadFile({\n      url: url,\n      filePath: opts.file,\n      name: opts.name,\n      formData: opts.data\n    })\n  } else {\n    [err, res = {}] = await uni.request({\n      url: `${API_BASE}${url}`,\n      header: {\n        &#039;Content-Type&#039;: &#039;application\/x-www-form-urlencoded&#039;\n      },\n      method: opts.method || &#039;POST&#039;,\n      timeout: opts.timeout || NETWORK_TIMEOUT,\n      data: opts.data || {}\n    })\n  }\n  err &amp;&amp; console.warn(`${url}\u63a5\u53e3\u9519\u8bef\uff1a`, err)\n  opts.debug &amp;&amp; console.info(&#039;\u63a5\u53e3\u7ed3\u679c\uff1a&#039;, res)\n  return new Promise((resolve, reject) =&gt; {\n    if (err) {\n      if (opts.handleFail !== false) {\n        showToast(NETWORK_ERR_MESSAGE)\n        return reject(res)\n      }\n    } else {\n      \/\/ 404, 502\u7b49\u670d\u52a1\u5668\u9519\u8bef\u4fe1\u606f\n      if (typeof res.data !== &#039;object&#039;) res.data = { status: res.statusCode, message: DEFAULT_ERR_MESSAGE, data: res.data } \n\n      if (res.data.status === &#039;200&#039;) {\n        return resolve(res.data)\n      } else if (res.data.status === &#039;403&#039; &amp;&amp; opts.handleLogin !== false) { \/\/ \u672a\u767b\u5f55\u6216\u8005\u767b\u5f55\u5931\u6548\n        showToast(&#039;\u8bf7\u5148\u767b\u5f55&#039;, 1000)\n        return uni.navigateTo({\n          url: &#039;\/pages\/login\/login&#039;\n        })\n      } else {\n        if (opts.handleFail !== false) {\n          showToast(res.data.message || DEFAULT_ERR_MESSAGE)\n        }\n        return reject(res)\n      }\n    }\n  })\n}<\/code><\/pre>\n<p>\u8bf4\u660e\uff0c\u4ee5\u4e0a<code>store<\/code>\u4e3a\u57fa\u4e8e<code>vuex<\/code>\u7684\u6570\u636e\u7ba1\u7406\uff0c\u4e0b\u6587\u4f1a\u5b9e\u73b0<\/p>\n<p>\u7b2c\u4e09\u6b65\uff0c\u5b9e\u73b0<code>get<\/code>\uff0c<code>post<\/code>\u4ee5\u53ca<code>upload<\/code>\u65b9\u6cd5<\/p>\n<pre><code class=\"language-javascript\">export function get(url, opts = {}) {\n  opts.method = &#039;GET&#039;\n  return request(url, opts)\n}\n\nexport function post(url, opts = {}) {\n  opts.method = &#039;POST&#039;\n  return request(url, opts)\n}\n\n\/**\n * @param {url} \u4e0a\u4f20\u5730\u5740\n * @param {file}  \u6587\u4ef6\u8def\u5f84\n * @param {name} \u6587\u4ef6\u7684\u8868\u5355\u540d\u79f0\n * @param {formData} \u989d\u5916\u9700\u8981\u63d0\u4ea4\u7684\u5b57\u6bb5\n * *\/\nexport async function upload(url, file, name = &#039;file&#039;, formData = {}) {\n  if (!file) return\n  formData.openid = formData.openid || store.getters.openid\n  if (formData.needAuth) {\n    const userinfo = await store.dispatch(&#039;user\/getUserInfo&#039;)\n    formData.openid = userinfo.openid || formData.openid\n    formData.token = userinfo.token\n  }\n  return handleRequest(url, {\n    file: file,\n    name: name,\n    data: formData\n  }, true)\n}<\/code><\/pre>\n<p>\u7b2c\u56db\u6b65\uff0c\u5bfc\u51fa\u54cd\u5e94\u7684\u65b9\u6cd5\uff1a<\/p>\n<pre><code class=\"language-javascript\">function install(Vue) {\n  Vue.prototype.$request = request\n  Vue.prototype.$get = get\n  Vue.prototype.$post = post\n  Vue.prototype.$upload = upload\n}\nexport default { install }<\/code><\/pre>\n<p>\u7b2c\u4e94\u6b65\uff0c\u5b89\u88c5\u65b9\u6cd5<\/p>\n<p>\u6253\u5f00<code>main.js<\/code>\u6587\u4ef6\uff0c\u5b89\u88c5\u5bf9\u5e94\u7684\u65b9\u6cd5<\/p>\n<pre><code class=\"language-javascript\">import request from &#039;@\/utils\/request&#039;\n\nVue.use(request)<\/code><\/pre>\n<p>\u505a\u5b8c\u4ee5\u4e0a\u5de5\u4f5c\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u50cf\u4e0b\u9762\u7684\u65b9\u5f0f\u5728\u9875\u9762\u4e0a\u8c03\u7528<code>http<\/code>\u76f8\u5173\u7684\u65b9\u6cd5<\/p>\n<pre><code class=\"language-javascript\">export default {\n  onLoad(){\n    this.getOrders()\n  },\n  methods: {\n    getOrders(){\n      this.$get(&#039;orders&#039;, {\n        needAuth: true,\n        data: {\n          userid: this.$store.getters.userinfo.id\n        }\n      }).then(res =&gt; {\n        console.log(res)\n      }).catch(res =&gt; {\n        console.warn(res)\n      })\n    }\n  }\n}<\/code><\/pre>\n<h4>\u5c0f\u7ed3<\/h4>\n<p>\u4ee5\u4e0a\u901a\u8fc7<code>Vue.use<\/code>\u5b89\u88c5\u7684\u65b9\u5f0f\uff0c\u5728<code>Vue<\/code>\u539f\u578b\u4e0a\u6269\u5c55\u516c\u5171\u7684\u65b9\u6cd5\uff0c\u4ece\u800c\u8fbe\u5230\u53ef\u4ee5\u5728\u9875\u9762\uff08<code>Vue<\/code>\u5b9e\u4f8b\uff09\u4e0a\u8c03\u7528\u5bf9\u5e94\u7684\u65b9\u6cd5\u6765\u5b9e\u73b0\u8c03\u7528\u63a5\u53e3\u7b49\u529f\u80fd\uff0c\u5982\u679c\u9700\u8981\u6269\u5c55\u66f4\u591a\u7684\u65b9\u6cd5\u548c\u5c5e\u6027\uff0c\u5747\u53ef\u4ee5\u4ee5\u8be5\u79cd\u65b9\u5f0f\u8fdb\u884c\u6269\u5c55\u3002<\/p>\n<h3>\u8def\u7531\u62e6\u622a<\/h3>\n<p>\u8def\u7531\u62e6\u622a\u51e0\u4e4e\u662f\u6bcf\u4e00\u4e2a\u5e94\u7528\u90fd\u9700\u8981\u7528\u5230\u7684\u529f\u80fd\uff0c\u6bd4\u5982\u9875\u9762\u8df3\u8f6c\u524d\u7684\u767b\u5f55\u5224\u65ad\u3002\u5728Vue\u6846\u67b6\u5f00\u53d1\u7684\u5355\u9875\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u4f1a\u7ed3\u5408<code>Vue-Router<\/code>\u6765\u5b9e\u73b0\u54cd\u5e94\u7684\u529f\u80fd\uff0c<code>Vue-Router<\/code>\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u8def\u7531\u5b88\u536b\uff0c\u5b9e\u73b0\u8def\u7531\u7684\u62e6\u622a\u5341\u5206\u4fbf\u5229\u3002\u7136\u800c\uff0c\u5728\u5c0f\u7a0b\u5e8f\u4e0a\u5b9e\u73b0\u8def\u7531\u62e6\u622a\u662f\u76f8\u5bf9\u6bd4\u8f83\u9ebb\u70e6\u7684\u3002<code>uni-app<\/code>\u793e\u533a\u4e0a\u4e5f\u6709\u4e00\u4e9b\u89e3\u51b3\u65b9\u6848\uff0c\u6bd4\u5982<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/ext.dcloud.net.cn\/plugin?id=578\" title=\"\u4e00\u4e2a\u5b8c\u5168\u76f8\u4f3cVue-router\u7684\u8def\u7531\u63d2\u4ef6\">\u4e00\u4e2a\u5b8c\u5168\u76f8\u4f3cVue-router\u7684\u8def\u7531\u63d2\u4ef6<\/a>\uff0c\u8be5\u63d2\u4ef6\u91cd\u5199\u4e86<code>uni-app<\/code>\u7684\u4e00\u4e9b\u65b9\u6cd5\u4ee5\u53ca\u751f\u547d\u94a9\u5b50\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u7edd\u5927\u90e8\u5206\u7684<code>Vue-Router<\/code>\u7684\u94a9\u5b50\uff0c\u6709\u5174\u8da3\u7684\u53ef\u4ee5\u4f7f\u7528\u8be5\u63d2\u4ef6\u3002<\/p>\n<p>\u5b9e\u9645\u60c5\u51b5\u662f\uff0c\u6211\u4eec\u5f80\u5f80\u4e0d\u9700\u8981\u50cf<code>Vue-Router<\/code>\u90a3\u6837\u5b8c\u6574\u7684\u8def\u7531\u62e6\u622a\uff0c\u6709\u65f6\u6211\u4eec\u4ec5\u4ec5\u53ea\u9700\u8981\u767b\u5f55\u524d\u7684\u4e00\u5c42\u7b80\u5355\u7684\u6821\u9a8c\uff0c\u8fd9\u6837\u5982\u679c\u5f15\u5165\u4e00\u4e2a\u5b8c\u6574\u7684\u8def\u7531\u62e6\u622a\u89e3\u51b3\u65b9\u6848\u4f1a\u663e\u5f97\u6709\u70b9\u5197\u4f59\uff0c\u540c\u65f6\uff0c\u4e5f\u4f1a\u8ba9\u5e94\u7528\u7684\u5305\u66f4\u52a0\u5927\uff08\u5c0f\u7a0b\u5e8f\u5747\u5bf9\u5355\u4e2a\u5305\u6709\u5927\u5c0f\u7684\u9650\u5236\uff09\u3002\u9762\u5bf9\u8fd9\u79cd\u60c5\u51b5\uff0c\u6211\u4eec\u4ec5\u9700\u8981\u505a\u4e00\u4e9b\u7b80\u5355\u7684\u6269\u5c55\u5373\u53ef\u8fbe\u5230\u6211\u4eec\u7684\u9700\u8981\u3002\u4ee5\u4e0b\uff0c\u4ee5\u767b\u5f55\u62e6\u622a\u4e3a\u4f8b\uff0c\u7b80\u5355\u7684\u5b9e\u73b0\u4e00\u4e0b\u8def\u7531\u7684\u62e6\u622a\u3002\u6211\u4eec\u7684\u9700\u6c42\u662f\uff0c\u5bf9\u4e8e\u9700\u8981\u767b\u5f55\u624d\u53ef\u4ee5\u8fdb\u5165\u7684\u9875\u9762\uff0c\u6211\u4eec\u5148\u505a\u4e00\u4e0b\u767b\u5f55\u6821\u9a8c\uff0c\u5982\u679c\u672a\u767b\u5f55\uff0c\u5219\u8df3\u8f6c\u524d\u5148\u8df3\u8f6c\u81f3\u767b\u5f55\u9875\u9762\u3002<\/p>\n<p>\u5728<code>utils<\/code>\u76ee\u5f55\u4e0b\u521b\u5efa<code>extends.js<\/code>\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u4e13\u95e8\u7528\u6765\u5bf9<code>uni-app<\/code>\u6846\u67b6\u505a\u4e00\u4e9b\u989d\u5916\u7684\u6269\u5c55\u3002\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-javascript\">import store from &#039;@\/store&#039;\n\nexport default function() {\n  [&#039;navigateTo&#039;, &#039;redirectTo&#039;, &#039;switchTab&#039;, &#039;navigateBack&#039;].map(item =&gt; {\n    const nativeFunc = uni[item]\n    uni[item] = function(opts, needAuth) {\n      if (needAuth) {\n        store.dispatch(&#039;user\/getUserInfo&#039;).then((res) =&gt; {\n          nativeFunc.call(this, opts)\n        })\n      } else {\n        return nativeFunc.call(this, opts)\n      }\n    }\n  })\n}<\/code><\/pre>\n<p>\u4ee3\u7801\u89e3\u8bfb\uff1a\u5bf9\u4e8e\u8def\u7531\u76f8\u5173\u7684\u51e0\u4e2a\u65b9\u6cd5\u8fdb\u884c\u904d\u5386\u5e76\u7f13\u5b58\u539f\u65b9\u6cd5\uff0c\u5728<code>uni<\/code>\u5bf9\u8c61\u4e0a\u91cd\u5199\u65b9\u6cd5\uff0c\u6bcf\u4e2a\u65b9\u6cd5\u589e\u52a0<code>needAuth<\/code>\u53c2\u6570\uff0c\u8868\u793a\u8df3\u8f6c\u524d\u662f\u5426\u9700\u8981\u767b\u5f55<\/p>\n<p>\u5982\u679c\u9700\u8981\u767b\u5f55\uff0c\u5219\u9996\u5148\u83b7\u53d6\u7528\u6237\u4fe1\u606f\uff0c\u5982\u679c\u83b7\u53d6\u4e0d\u5230\u7528\u6237\u4fe1\u606f\uff0c\u5c06\u4f1a\u81ea\u52a8\u8df3\u8f6c\u5230\u767b\u5f55\u9875\uff08<code>store<\/code>\u91cc\u9762\u7684<code>user<\/code>\u6a21\u5757\u505a\u7684\uff09\uff0c\u5426\u5219\u83b7\u53d6\u5230\u4fe1\u606f\u5c31\u8c03\u7528\u7f13\u5b58\u8d77\u6765\u7684\u539f\u65b9\u6cd5\uff0c\u5b9e\u73b0\u8df3\u8f6c\u3002\u5982\u679c\u4e0d\u9700\u8981\u767b\u5f55\uff0c\u5219\u76f4\u63a5\u8c03\u7528\u539f\u65b9\u6cd5<\/p>\n<p>\u6253\u5f00<code>main.js<\/code>\uff0c\u5f15\u5165\u8be5\u6587\u4ef6\u5e76\u6267\u884c<\/p>\n<pre><code class=\"language-javascript\">import uniExtend from &#039;@\/utils\/extends&#039;\n\nuniExtend()<\/code><\/pre>\n<p>\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u6269\u5c55\uff0c\u6211\u4eec\u5c31\u5b9e\u73b0\u4e86\u4e00\u4e2a\u8df3\u8f6c\u524d\u7684\u767b\u5f55\u62e6\u622a\u3002\u9664\u4e86\u767b\u5f55\u62e6\u622a\u5916\uff0c\u9488\u5bf9<code>uni-app<\/code>\u4e0a\u63d0\u4f9b\u539f\u751f\u65b9\u6cd5\uff0c\u5747\u53ef\u4ee5\u4ee5\u8be5\u65b9\u5f0f\u8fdb\u884c\u6269\u5c55\u3002<\/p>\n<blockquote>\n<p>\u7531\u4e8e\u5c0f\u7a0b\u5e8f\u7684\u9650\u5236\uff0c\u62e6\u622a\u5fc5\u987b\u8c03\u7528<code>uni-app<\/code>\u4e0a\u5bf9\u5e94\u7684\u8def\u7531\u65b9\u6cd5\uff0c\u901a\u8fc7\u5176\u4ed6\u9014\u5f84\u8df3\u8f6c\u9875\u9762\uff0c\u65e0\u6cd5\u62e6\u622a\u3002\u5305\u62ec\u4ee5\u4e0a\u793e\u533a\u4e0a\u63d0\u4f9b\u7684\u62e6\u622a\u65b9\u6848\u4e00\u6837\u53d7\u8fd9\u4e2a\u9650\u5236<\/p>\n<\/blockquote>\n<h3>\u72b6\u6001\u7ba1\u7406\u5668Vuex<\/h3>\n<p>\u4e00\u4e2a\u96c6\u4e2d\u5f0f\u7684\u72b6\u6001\u7ba1\u7406\u65b9\u6848\u5728\u4e00\u4e2a\u5e94\u7528\u4e2d\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\uff0c\u800cuniapp\u672c\u8eab\u662f\u652f\u6301\u6574\u5408<code>Vuex<\/code>\u7684\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5728\u8be5\u9879\u76ee\u4e2d\uff0c\u4e5f\u96c6\u6210\u4e86<code>Vuex<\/code>\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5728\u6839\u76ee\u5f55\u4e0b\u521b\u5efa<code>store<\/code>\u76ee\u5f55\uff0c\u4e13\u95e8\u7528\u4e8e\u5b58\u653e\u72b6\u6001\u7ba1\u7406\u76f8\u5173\u7684\u6587\u4ef6\u3002\u4e3a\u4e86\u8ba9\u6240\u6709\u7684\u72b6\u6001\u7ed3\u6784\u66f4\u52a0\u6e05\u6670\uff0c\u66f4\u597d\u7ef4\u62a4\uff0c\u6211\u4eec\u91c7\u7528<code>vuex<\/code>\u7684<code>modules<\/code>\u6765\u7ba1\u7406\u5404\u4e2a\u6a21\u5757\u7684\u6570\u636e\u3002\u6211\u4eec\u5728<code>store<\/code>\u76ee\u5f55\u4e0b\u521b\u5efa<code>modules<\/code>\u76ee\u5f55\u548c<code>index.js<\/code>\u6587\u4ef6\uff0c\u524d\u8005\u7528\u4e8e\u7ba1\u7406\u5404\u4e2a\u6570\u636e\u6a21\u5757\uff0c\u540e\u8005\u7528\u4e8e\u5bfc\u51fa\u76f8\u5173\u7684\u6570\u636e\u3002\u6b64\u65f6\uff0c\u9879\u76ee\u7684\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u524d\u7aef\/uni-app%20Vuex\u76ee\u5f55\u7ed3\u6784.png\" alt=\"uni-app Vuex\u76ee\u5f55\u7ed3\u6784\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4ee5\u7528\u6237\u6a21\u5757\u4e3a\u4f8b\uff0c\u6765\u5b9e\u73b0\u4e00\u4e2a\u57fa\u4e8e<code>vuex<\/code>\u7684\u72b6\u6001\u7ba1\u7406\u5668\u3002<\/p>\n<p>\u6253\u5f00<code>store\/index.js<\/code>\u6587\u4ef6\uff0c\u5199\u5165\u4ee5\u4e0b\u4ee3\u7801<\/p>\n<pre><code class=\"language-javascript\">import Vue from &#039;vue&#039;\nimport Vuex from &#039;vuex&#039;\n\nconst modules = require.context(&#039;.\/modules&#039;, true, \/.js$\/)\nlet moduleArr = []\nmodules.keys().map(key =&gt; {\n  moduleArr[key.replace(\/(\\.\\\/)|(\\.js)\/ig, &#039;&#039;)] = modules(key).default\n})\n\nVue.use(Vuex)\n\nconst store = new Vuex.Store({\n  modules: {\n    ...moduleArr\n  }\n})\n\nexport default store<\/code><\/pre>\n<p>\u8bf4\u660e\uff1a\u6b64\u5904\u8bfb\u53d6<code>modules<\/code>\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\uff0c\u83b7\u53d6\u6240\u6709\u7684<code>module<\/code>\uff0c\u8fd9\u8981\u6c42<code>module<\/code>\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u90fd\u662f\u5bfc\u51fa\u4e00\u4e2a<code>vuex<\/code>\u6a21\u5757\u3002\u53ef\u4ee5\u6309\u7167\u5b9e\u9645\u60c5\u51b5\uff0c\u4fee\u6539\u4ee5\u4e0a\u4ee3\u7801<\/p>\n<p>\u63a5\u7740\uff0c\u6253\u5f00<code>main.js<\/code>\u6587\u4ef6\uff0c\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-javascript\">import store from &#039;.\/store&#039;\n\nconst app = new Vue({\n  store,\n  ...App\n})<\/code><\/pre>\n<p>\u5230\u8fd9\u91cc\uff0c\u5df2\u7ecf\u7b80\u5355\u7684\u5b9e\u73b0\u4e86\u5728\u5e94\u7528\u4e0a\u4f7f\u7528<code>Vuex<\/code>\u3002\u63a5\u4e0b\u6765\uff0c\u6dfb\u52a0\u7528\u6237\u6a21\u5757\uff0c\u5728<code>modules<\/code>\u76ee\u5f55\u4e0b\u521b\u5efa<code>user.js<\/code>\u6587\u4ef6\u3002\u901a\u5e38\u4e00\u4e2a<code>module<\/code>\u5305\u542b<code>state<\/code>\uff0c<code>mutations<\/code>\u548c<code>actions<\/code>\u3002\u9996\u5148\u6211\u4eec\u5b9e\u73b0\u4e00\u4e0b<code>state<\/code>\uff0c\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre><code class=\"language-javascript\">const KEYS = [&#039;token&#039;, &#039;openid&#039;, &#039;unionid&#039;]\n\nconst getDefaultState = () =&gt; {\n  const result = {}\n  KEYS.map(key =&gt; {\n    result[key] = uni.getStorageSync(key) || &#039;&#039;\n  })\n  return result\n}\n\nconst state = getDefaultState()<\/code><\/pre>\n<p>\u5b9a\u4e49\u4e00\u4e2a<code>state<\/code>\u51fd\u6570\uff0c\u7528\u4e8e\u8bbe\u7f6e\u8fdb\u5165\u9875\u9762\u65f6\u9ed8\u8ba4\u7684<code>state<\/code>\uff0c\u6211\u4eec\u4f1a\u4f18\u5148\u8bfb\u53d6\u672c\u5730\u7f13\u5b58\u91cc\u7684\u7528\u6237\u6388\u6743\u4fe1\u606f\uff0c\u6bcf\u6b21\u767b\u5f55\u6388\u6743\u540e\uff0c\u4f1a\u5c06\u6388\u6743\u4fe1\u606f\u5b58\u5165\u672c\u5730\u7f13\u5b58\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u6388\u6743\u7684\u4fe1\u606f\u5305\u542b<code>token<\/code>,<code>openid<\/code>\u548c<code>unionid<\/code>\u4e09\u4e2a\u4fe1\u606f\uff08\u6b63\u5e38\u5e94\u8be5\u8d70\u5c0f\u7a0b\u5e8f\u7684\u6388\u6743\u7b49\u64cd\u4f5c\uff0c\u8fd9\u91cc\u4ec5\u4f5c\u6570\u636e\u6a21\u62df\uff09\u3002\u63a5\u7740\u5b9e\u73b0\u4e00\u4e0b<code>mutations<\/code>\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-javascript\">const mutations = {\n  SET_AUTH: (state, info) =&gt; { \/\/ \u8bbe\u7f6etoken\u7b49\u4fe1\u606f\n    KEYS.map(key =&gt; {\n      if (typeof info[key] !== &#039;undefined&#039;) {\n        state[key] = info[key]\n        uni.setStorageSync(key, info[key])\n      }\n    })\n  }\n}<\/code><\/pre>\n<p>\u5728\u8fd9\u91cc\uff0c\u6211\u53ea\u5b9a\u4e49\u4e86\u4e00\u4e2a\u8bbe\u7f6e\u6388\u6743\u4fe1\u606f\u7684<code>mutation<\/code>\uff0c\u4f20\u5165\u6388\u6743\u540e\u7684\u4fe1\u606f\uff0c\u5982\u679c\u5bf9\u5e94\u7684\u6388\u6743\u4fe1\u606f\u4e0d\u4e3a<code>undefined<\/code>\uff0c\u5219\u5c06\u4fe1\u606f\u8bbe\u7f6e\u5230<code>state<\/code>\u5e76\u4e14\u7f13\u5b58\u5728\u672c\u5730\u3002\u7136\u540e\u518d\u5b9e\u73b0\u4e00\u4e0b<code>actions<\/code>\u3002<code>actions<\/code>\u8d1f\u8d23\u767b\u5f55\u4ee5\u53ca\u7528\u6237\u4fe1\u606f\u7684\u83b7\u53d6\u3002\u4e3b\u8981\u5305\u62ec\u767b\u5f55\u3001\u767b\u51fa\u3001\u83b7\u53d6\u7528\u6237\u4fe1\u606f\u548c\u6388\u6743\u4fe1\u606f\u7b49\uff0c\u5b9e\u73b0\u5206\u522b\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u83b7\u53d6\u6388\u6743\u4fe1\u606f<\/li>\n<\/ul>\n<p>\u5982\u679c\u5df2\u7ecf\u6388\u6743\u8fc7\u4e86\uff0c\u5219\u76f4\u63a5\u8fd4\u56de\u6388\u6743\u4fe1\u606f\uff0c\u5426\u5219\u7684\u8bdd\u4f1a\u8df3\u8f6c\u81f3\u767b\u5f55\u9875\uff0c\u8fdb\u884c\u767b\u5f55<\/p>\n<pre><code class=\"language-javascript\">getAuth({ state }) { \/\/ \u83b7\u53d6\u7528\u6237\u6388\u6743\u4fe1\u606f\n  return new Promise(resolve =&gt; {\n    if (state.token) { \/\/ \u5df2\u6388\u6743\uff0c\u76f4\u63a5\u8fd4\u56de\n      resolve({\n        openid: state.openid,\n        token: state.token,\n        unionid: state.unionid\n      })\n    } else { \/\/ \u672a\u6388\u6743\uff0c\u8df3\u8f6c\u5230\u767b\u5f55\u9875\n      uni.navigateTo({\n        url: `\/pages\/login\/login`\n      })\n    }\n  })\n}<\/code><\/pre>\n<ul>\n<li>\u767b\u5f55\u4e0e\u767b\u51fa<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">login({state, commit, dispatch}, data) {\n  return new Promise((resolve, reject) =&gt; {\n    setTimeout(() =&gt; {\n      if(data.name === &#039;test&#039; &amp;&amp; data.password === &#039;test&#039;) {\n        const data = {\n          token: &quot;testToken&quot;,\n          openid: &quot;testOpenId&quot;,\n          unionid: &quot;testUnionId&quot;\n        }\n        commit(&#039;SET_AUTH&#039;, data)\n        resolve(data)\n      } else {\n        reject({\n          message: &quot;\u8d26\u53f7\u6216\u5bc6\u7801\u9519\u8bef&quot;,\n          code: &#039;100401&#039;\n        })\n      }\n\n    }, 1000)\n  })\n},\n\nlogout({ commit, dispatch }) { \/\/ \u9000\u51fa\u767b\u5f55\n  commit(&#039;SET_AUTH&#039;, {\n    openid: &#039;&#039;,\n    token: &#039;&#039;,\n    unionid: &#039;&#039;\n  })\n  return Promise.resolve()\n}<\/code><\/pre>\n<p>\u4ee5\u4e0a\u6a21\u62df\u4e86\u4e00\u4e2a\u8d26\u53f7\u767b\u5f55\uff0c\u5f53\u767b\u5f55\u540e\uff0c\u8fd4\u56de<code>token<\/code>\u7b49\u6388\u6743\u4fe1\u606f\uff0c\u5e76\u8c03\u7528<code>commit(&#039;SET_AUTH&#039;, data)<\/code>\u66f4\u65b0<code>state<\/code>\u4ee5\u53ca\u672c\u5730\u7f13\u5b58\uff1b\u767b\u51fa\u65f6\u5219\u6e05\u7a7a\u6240\u6709\u7684\u767b\u5f55\u6388\u6743\u4fe1\u606f\u3002\u6700\u540e\u518d\u5b9e\u73b0\u7528\u6237\u4fe1\u606f\u83b7\u53d6\u7684<code>action<\/code>\uff1a<\/p>\n<pre><code class=\"language-javascript\">getUserInfo({state, commit, dispatch}) { \/\/ \u672c\u5730\u83b7\u53d6\u7528\u6237\u4fe1\u606f\n  return new Promise(resolve =&gt; {\n    dispatch(&#039;getAuth&#039;).then(res =&gt; {\n      resolve({\n        username: &quot;test&quot;,\n        age: 18,\n        email: &quot;test@test.test&quot;\n      })\n    })\n  })\n}<\/code><\/pre>\n<p>\u5f53\u83b7\u53d6\u7528\u6237\u4fe1\u606f\u65f6\uff0c\u9996\u5148\u4f1a\u8fdb\u884c\u767b\u5f55\u6388\u6743\uff0c\u6388\u6743\u6210\u529f\u540e\u5219\u6a21\u62df\u8fd4\u56de\u7528\u6237\u4fe1\u606f\u3002\u5230\u8fd9\u91cc\u4e00\u4e2a\u7b80\u5355\u7684\u4e0e\u7528\u6237\u76f8\u5173\u7684<code>Vuex<\/code>\u6a21\u5757\u5c31\u5b8c\u6210\u4e86\u3002\u6700\u540e\u5c31\u662f\u5bfc\u51fa\u6a21\u5757\u4f9b\u5e94\u7528\u4f7f\u7528\uff1a<\/p>\n<pre><code class=\"language-javascript\">export default {\n  namespaced: true,\n  state,\n  mutations,\n  actions\n}<\/code><\/pre>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u9875\u9762\u8bbf\u95ee<code>state<\/code>\u6570\u636e\uff0c\u901a\u5e38\u6211\u4eec\u8fd8\u4f1a\u521b\u5efa\u4e00\u4e9b<code>getters<\/code>\u3002\u5728<code>store<\/code>\u76ee\u5f55\u4e0b\u65b0\u5efa\u6587\u4ef6<code>getters.js<\/code>\uff0c\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-javascript\">const getters = {\n  openid: state =&gt; state.user.openid,\n  token: state =&gt; state.user.token,\n  unionid: state =&gt; state.user.unionid\n}\n\nexport default getters<\/code><\/pre>\n<p>\u6253\u5f00<code>store\/index.js<\/code>\uff0c\u4fee\u6539\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-javascript\">import getters from &#039;.\/getters&#039;\n\nconst store = new Vuex.Store({\n  modules: {\n    ...moduleArr\n  },\n  getters\n})<\/code><\/pre>\n<p>\u8fd9\u6837\uff0c\u5c31\u53ef\u4ee5\u5728\u9875\u9762\u4e0a\u4f7f\u7528<code>this.$store.getters.token<\/code>\u4ee5\u53ca\u4f7f\u7528<code>Vuex<\/code>\u7684<code>mapGetters<\/code>\u65b9\u6cd5\u6765\u8bbf\u95ee\u6211\u4eec\u7684<code>getters<\/code>\u4e86\u3002<\/p>\n<p><code>mapGetters<\/code>\u548c<code>mapState<\/code>\u7b49\u8f85\u52a9\u51fd\u6570\u5747\u53ef\u4ee5\u4f7f\u7528<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u4e00\u4e2a\u7b80\u5355\u7684\u6570\u636e\u7ba1\u7406\u5668\u5c31\u7b97\u5b8c\u6210\u4e86\uff0c\u5982\u679c\u9700\u8981\u6dfb\u52a0\u66f4\u591a\u7684\u6570\u636e\u72b6\u6001\uff0c\u53ef\u4ee5\u6309\u7167\u7528\u6237\u6a21\u5757\u7684\u7ec4\u7ec7\u65b9\u5f0f\u5bf9\u6570\u636e\u8fdb\u884c\u7ba1\u7406\u3002\u6709\u4e86\u6570\u636e\u7ba1\u7406\u4ee5\u53ca\u6570\u636e\u8bf7\u6c42\u7b49\u57fa\u7840\u6a21\u5757\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u5177\u4f53\u7684\u4e1a\u52a1\u9875\u9762\u3002\u4e0b\u9762\u6211\u4eec\u4ee5\u7528\u6237\u767b\u5f55\u4e0e\u4fe1\u606f\u83b7\u53d6\u4e3a\u4f8b\uff0c\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u4e1a\u52a1\u9875\u9762\u3002<\/p>\n<h3>\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50&#8211;\u767b\u5f55\u4e0e\u4fe1\u606f\u83b7\u53d6<\/h3>\n<p>\uff081\uff09\u4fee\u6539<code>pages\/index\/index<\/code>\u4e3a\u5982\u4e0b\u4ee3\u7801<\/p>\n<pre><code class=\"language-html\">&lt;template&gt;\n  &lt;view class=&quot;container&quot;&gt;\n    &lt;view&gt;\u7528\u6237\u540d\uff1a{{userinfo.username}}&lt;\/view&gt;\n    &lt;view&gt;\u5e74\u9f84\uff1a{{userinfo.age}}&lt;\/view&gt;\n    &lt;view&gt;\u90ae\u7bb1\uff1a{{userinfo.email}}&lt;\/view&gt;\n    &lt;button @tap=&quot;logout&quot; type=&quot;warn&quot; style=&quot;margin-top: 30rpx;&quot; v-if=&quot;userinfo.username&quot;&gt;\u9000\u51fa\u767b\u5f55&lt;\/button&gt;\n    &lt;button @tap=&quot;getUserinfo&quot; type=&quot;primary&quot; style=&quot;margin-top: 30rpx;&quot; v-else&gt;\u83b7\u53d6\u7528\u6237\u4fe1\u606f&lt;\/button&gt;\n  &lt;\/view&gt;\n&lt;\/template&gt;<\/code><\/pre>\n<pre><code class=\"language-javascript\">export default {\n  data() {\n    return {\n      userinfo: {\n        username: &quot;&quot;,\n        email: &quot;&quot;,\n        age: &quot;&quot;\n      }\n    }\n  },\n  methods: {\n    getUserinfo() {\n      this.$store.dispatch(&#039;user\/getUserInfo&#039;).then(res =&gt; {\n        this.userinfo = res\n      })\n    },\n    logout() {\n      this.$store.dispatch(&#039;user\/logout&#039;).then(() =&gt;{\n        this.userinfo.username = &quot;&quot;\n        this.userinfo.age = &quot;&quot;\n        this.userinfo.email = &quot;&quot;\n      })\n    }\n  },\n  onUnload() {\n    uni.$off(&quot;loginSuccess&quot;, this.getUserinfo)\n  },\n  onLoad() {\n    uni.$on(&quot;loginSuccess&quot;, this.getUserinfo)\n  }\n}<\/code><\/pre>\n<p><code>uni.$off<\/code>\u548c<code>uni.$on<\/code>\u4e3a<code>uni-app<\/code>\u7684\u901a\u4fe1\u65b9\u6848\uff0c\u540e\u6587\u4f1a\u8bb2\u8ff0<\/p>\n<p>\u52a0\u4e0a\u6837\u5f0f\u540e\uff0c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u524d\u7aef\/uni-app\u83b7\u53d6\u7528\u6237\u4fe1\u606f\u9875.png\" alt=\"uni-app\u83b7\u53d6\u7528\u6237\u4fe1\u606f\u9875\" \/><\/p>\n<p>\uff082\uff09\u63a5\u7740\u5b9e\u73b0\u767b\u5f55\u9875\u9762\u3002\u5728<code>pages<\/code>\u76ee\u5f55\u4e0b\u65b0\u5efa<code>login\/login.vue<\/code>\u6587\u4ef6\u3002\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-html\">&lt;template&gt;\n  &lt;view class=&quot;wrap&quot;&gt;\n    &lt;view class=&quot;form-item&quot;&gt;\n      &lt;input v-model.trim=&quot;name&quot; type=&quot;text&quot; placeholder=&quot;\u8bf7\u8f93\u5165\u7528\u6237\u540d&quot; class=&quot;input&quot;&gt;\n    &lt;\/view&gt;\n    &lt;view class=&quot;form-item&quot;&gt;\n      &lt;input v-model.trim=&quot;password&quot; type=&quot;password&quot; placeholder=&quot;\u8bf7\u8f93\u5165\u5bc6\u7801&quot; class=&quot;input&quot;&gt;\n    &lt;\/view&gt;\n    &lt;view class=&quot;button&quot; @tap=&quot;submit&quot;&gt;\u767b\u5f55&lt;\/view&gt;\n  &lt;\/view&gt;\n&lt;\/template&gt;<\/code><\/pre>\n<pre><code class=\"language-javascript\">export default {\n  data() {\n    return {\n      name: &#039;&#039;,\n      password: &#039;&#039;\n    }\n  },\n  methods: {\n    valid() {\n      if (!this.name) {\n        return this.$toast(&#039;\u8bf7\u8f93\u5165\u7528\u6237\u540d&#039;)\n      }\n      if (!this.password) {\n        return this.$toast(&#039;\u8bf7\u8f93\u5165\u5bc6\u7801&#039;)\n      }\n      return true\n    },\n    submit: function() {\n      if (!this.valid()) return\n      uni.showLoading({\n        title: &quot;\u6b63\u5728\u767b\u5f55...&quot;\n      })\n      this.$store.dispatch(&#039;user\/login&#039;, {\n        name: this.name,\n        password: this.password\n      }).then(res =&gt; {\n        console.log(res)\n        uni.$emit(&quot;loginSuccess&quot;, res)\n        uni.navigateBack()\n      }).catch(res =&gt; {\n        this.$toast(res.message)\n      }).finally(() =&gt; {\n        uni.hideLoading()\n      })\n    }\n  },\n  onLoad() {\n    this.$store.dispatch(&#039;user\/logout&#039;)\n  }\n}<\/code><\/pre>\n<p>\u903b\u8f91\u6bd4\u8f83\u7b80\u5355\uff0c\u8fdb\u5165\u9875\u9762\u540e\u4f7f\u7528<code>this.$store.dispatch(&#039;user\/logout&#039;)<\/code>\u6e05\u7a7a\u539f\u6709\u7684\u767b\u5f55\u72b6\u6001\uff0c\u767b\u5f55\u6210\u529f\u540e\u53d1\u5e03\u4e8b\u4ef6<code>loginSuccess<\/code>\u5e76\u8fd4\u56de\u4e0a\u4e00\u9875\uff0c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u524d\u7aef\/uni-app\u7528\u6237\u767b\u5f55\u9875.png\" alt=\"uni-app\u7528\u6237\u767b\u5f55\u9875\" \/><\/p>\n<p>\u4ee5\u4e0a\u4e24\u4e2a\u9875\u9762\u5b8c\u6210\u540e\uff0c\u5b8c\u6574\u7684\u64cd\u4f5c\u6f14\u793a\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u524d\u7aef\/uni-app\u5b8c\u6574\u64cd\u4f5c\u6f14\u793a.png\" alt=\"uni-app\u5b8c\u6574\u64cd\u4f5c\u6f14\u793a\" \/><\/p>\n<h3>\u6570\u636e\u901a\u4fe1\u65b9\u6848<\/h3>\n<p>\u5728<code>uni-app<\/code>\u4e2d\uff0c\u6570\u636e\u7684\u901a\u4fe1\u901a\u5e38\u5305\u542b\u7ec4\u4ef6\u4e4b\u95f4\u7684\u901a\u4fe1\u4ee5\u53ca\u9875\u9762\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u540c\u6837\uff0c\u5728\u5c0f\u7a0b\u5e8f\u4e2d\u4e00\u822c\u4e5f\u5305\u542b\u8fd9\u4e24\u79cd\u901a\u4fe1\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u53ea\u8ba8\u8bba\u9875\u9762\u4e4b\u95f4\u7684\u6570\u636e\u901a\u4fe1\uff08\u7ec4\u4ef6\u4e4b\u95f4\u7684\u901a\u4fe1\u53c2\u7167Vue\u5b98\u65b9\u7684\u7ec4\u4ef6\u901a\u4fe1\uff09\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u5728<code>uni-app<\/code>\u4e2d\u6211\u4eec\u6709\u4ee5\u4e0b\u7684\u51e0\u79cd\u65b9\u5f0f\u6765\u5b9e\u73b0\u9875\u9762\u4e4b\u95f4\u7684\u901a\u4fe1\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528<code>url<\/code>\u4f20\u53c2<\/li>\n<li>\u4f7f\u7528\u672c\u5730\u7f13\u5b58<\/li>\n<li>\u4f7f\u7528\u5168\u5c40\u6570\u636e\uff08\u5982\u5c0f\u7a0b\u5e8f\u7684<code>globalData<\/code>)<\/li>\n<li>\u4f7f\u7528<code>getCurrentPage<\/code>\u65b9\u6cd5\u83b7\u53d6\u5bf9\u5e94\u7684\u9875\u9762\u8fdb\u884c\u901a\u4fe1<\/li>\n<li>\u4f7f\u7528<code>eventBus<\/code><\/li>\n<li>\u4f7f\u7528<code>uni-app<\/code>\u81ea\u5e26\u7684\u4e8b\u4ef6\u53d1\u5e03\u8ba2\u9605<\/li>\n<li>\u4f7f\u7528<code>Vuex<\/code><\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u51e0\u79cd\u65b9\u6848\u4e2d\uff0c\u524d4\u4e2d\u65b9\u6848\u5728\u5e94\u7528\u53d8\u5f97\u8d8a\u6765\u8d8a\u590d\u6742\u7684\u65f6\u5019\uff0c\u4f1a\u4f7f\u9875\u9762\u4e4b\u95f4\u7684\u8026\u5408\u5ea6\u53d8\u5f97\u8d8a\u6765\u8d8a\u9ad8\uff0c\u4ece\u800c\u4e0d\u5229\u4e8e\u5e94\u7528\u7684\u7ef4\u62a4\u3002\u56e0\u6b64\uff0c\u901a\u5e38\u9875\u9762\u4e4b\u95f4\u7684\u6570\u636e\u901a\u4fe1\u6211\u4eec\u4f1a\u91c7\u7528\u540e\u4e09\u79cd\u65b9\u6848\u3002\u6bd4\u5982\u524d\u9762\u7684\u767b\u5f55\u64cd\u4f5c\u4f8b\u5b50\u4e2d\uff0c\u5219\u662f\u4f7f\u7528\u4e86<code>uni-app<\/code>\u81ea\u5e26\u7684\u4e8b\u4ef6\u53d1\u5e03\u8ba2\u9605\u901a\u4fe1\u7684\u65b9\u6848\u3002\u5176\u672c\u8d28\u4e0a\u4e5f\u662f\u4e00\u4e2a<code>eventBus<\/code>\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u8fd9\u4e0d\u662f\u8bf4\u524d4\u4e2d\u65b9\u6848\u5c31\u4e0d\u80fd\u5728\u5e94\u7528\u4e2d\u4f7f\u7528\uff0c\u67d0\u4e9b\u573a\u666f\u4f7f\u7528\u524d\u56db\u79cd\u65b9\u6848\u53ef\u80fd\u4f1a\u66f4\u7b80\u6d01\u3001\u65b9\u4fbf\u3001\u751a\u81f3\u662f\u5fc5\u987b\u7684\u3002\u6bd4\u5982\u901a\u8fc7url\u53c2\u6570\u533a\u5206\u6e20\u9053\uff0c\u8bb0\u4f4f\u67d0\u4e9b\u72b6\u6001\uff08\u672c\u5730\u7f13\u5b58\uff09\u7b49\u3002\u5728\u5b9e\u9645\u64cd\u4f5c\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5e94\u8be5\u7075\u6d3b\u9009\u62e9\u3001\u7075\u6d3b\u5e94\u7528\u3002<\/p>\n<p><code>uni-app<\/code>\u7684\u4e8b\u4ef6\u53d1\u5e03\u8ba2\u9605\uff0c\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/uniapp.dcloud.io\/api\/window\/communication\" title=\"\u9875\u9762\u901a\u4fe1\">\u9875\u9762\u901a\u4fe1<\/a><\/p>\n<p>\u4f7f\u7528\u7684\u65f6\u5019\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<ul>\n<li>\u8ba2\u9605\u4e86\u4e8b\u4ef6\u540e\u5728\u9875\u9762\u9500\u6bc1\u65f6\u8bb0\u5f97\u53d6\u6d88\u8ba2\u9605\uff0c\u4f7f\u7528<code>uni.$off<\/code><\/li>\n<li>\u4f7f\u7528<code>uni.$off<\/code>\u5efa\u8bae\u4f20\u9012\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff0c\u53d6\u6d88\u5f53\u524d\u9875\u9762\u7684\u8ba2\u9605\uff0c\u800c\u4e0d\u662f\u53d6\u6d88\u6240\u6709\u7684\u8ba2\u9605\u3002\u8fd9\u9700\u8981\u5728\u8ba2\u9605\u7684\u65f6\u5019\u4e5f\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570\uff0c\u4e24\u4e2a\u56de\u8c03\u5e94\u6307\u5411\u540c\u4e00\u4e2a\u5f15\u7528<\/li>\n<\/ul>\n<h3>\u81ea\u5b9a\u4e49\u7ec4\u4ef6<\/h3>\n<p>\u7ec4\u4ef6\u5316\u662f<code>Vue<\/code>\u7684\u4e00\u4e2a\u6838\u5fc3\u4e4b\u4e00\uff0c\u4f7f\u7528<code>uni-app<\/code>\u540c\u6837\u652f\u6301\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u3002\u4f46\u662f\uff0c\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5728\u5404\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u7531\u4e8e\u5b9e\u73b0\u7684\u65b9\u6848\u5e76\u4e0d\u4e00\u81f4\uff0c\u6240\u4ee5\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5e76\u4e0d\u603b\u662f\u80fd\u5b8c\u7f8e\u7684\u8fd0\u884c\u5728\u5404\u4e2a\u7aef\u7684\u5c0f\u7a0b\u5e8f\u4e2d\u3002\u8fd9\u9700\u8981\u5728\u5b9e\u73b0\u7684\u8fc7\u7a0b\u505a\u4e00\u4e9b\u7279\u6b8a\u7684\u517c\u5bb9\u5904\u7406\u3002\u67e5\u770b<code>uni-app<\/code>\u5b98\u65b9\u7684\u7ec4\u4ef6\u5e93\u6e90\u7801\uff0c\u540c\u6837\u4e5f\u4f1a\u4e3a\u5404\u4e2a\u5e73\u53f0\u5199\u4e00\u4e9b\u517c\u5bb9\u4ee3\u7801\u3002\u672c\u6587\u4e0d\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4e00\u6b65\u4e00\u6b65\u7684\u5199\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u7ec4\u4ef6\u3002\u6309\u7167\u5b98\u65b9\u7ec4\u4ef6\u5e93\u7684\u89c4\u8303\uff0c\u5b9e\u6218\u4e2d\u6211\u4eec\u901a\u5e38\u4f1a\u9075\u5faa\u4ee5\u4e0b\u51e0\u4e2a\u539f\u5219\uff1a<\/p>\n<ul>\n<li>\u4e0e\u4e1a\u52a1\u65e0\u5173\u7684\u901a\u7528\u7ec4\u4ef6\u653e\u7f6e\u5728\u6839\u76ee\u5f55\u7684\u4e0b\u7684<code>compoments<\/code>\u76ee\u5f55\u4e0b\uff0c\u540c\u65f6\uff0c\u9700\u8981\u653e\u7f6e\u5728\u989d\u5916\u7684\u76ee\u5f55\uff0c\u65b9\u4fbf\u7edf\u4e00\u7ba1\u7406\uff0c\u5982<code>components\/my-component<\/code><\/li>\n<li>\u4e1a\u52a1\u7ec4\u4ef6\u653e\u7f6e\u5728\u5bf9\u5e94\u9875\u9762\u6a21\u5757\u7684<code>components<\/code>\u76ee\u5f55\u4e0b\uff0c\u5982<code>pages\/login\/components\/phoneLogin\/phoneLogin.vue<\/code><\/li>\n<li>\u7ec4\u4ef6\u7684\u547d\u540d\u65b9\u5f0f\u91c7\u7528\u6a2a\u7ebf\u8fde\u63a5\u7684\u65b9\u5f0f\uff0c\u5982<code>my-dialog<\/code><\/li>\n<li>\u7ec4\u4ef6\u9700\u8981\u653e\u7f6e\u5728\u540c\u540d\u76ee\u5f55\u4e0b\uff0c\u5982<code>components\/my-components\/my-dialog\/my-dialog.vue<\/code><\/li>\n<li>\u7ec4\u4ef6\u7684\u6837\u5f0f\u7c7b\u578b\u6700\u597d\u91c7\u7528<code>BEM<\/code>\u89c4\u8303\u7684\u547d\u540d\u65b9\u5f0f<\/li>\n<li>\u5982\u679c\u9700\u8981\u6269\u5c55<code>uni-app<\/code>\u5b98\u65b9\u7684\u7ec4\u4ef6\uff0c\u4e0d\u5e94\u8be5\u4fee\u6539\u6e90\u7801\uff0c\u91c7\u7528\u62f7\u8d1d\u7684\u65b9\u5f0f\u62f7\u8d1d\u5230\u81ea\u5b9a\u4e49\u7684\u7ec4\u4ef6\u76ee\u5f55\uff0c\u540c\u65f6\uff0c\u7ec4\u4ef6\u547d\u540d\u4e0d\u8981\u4ee5<code>uni-<\/code>\u5f00\u5934<\/li>\n<\/ul>\n<blockquote>\n<p>\u5728\u4f7f\u7528\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u65f6\uff0c\u7f16\u8bd1\u5230\u5404\u4e2a\u7aef\u65f6\u5e76\u4e0d\u662f\u4e00\u5e06\u98ce\u987a\u7684\uff0c\u8fd9\u4e3b\u8981\u662f\u4e0d\u540c\u5e73\u53f0\u7684\u5c0f\u7a0b\u5e8f\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5b9e\u73b0\u7684\u65b9\u5f0f\u4e0d\u540c\u3002\u5982\u679c\u5728\u652f\u4ed8\u5b9d\u4e0b\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u7f16\u8bd1\u65b9\u5f0f\u4e3a<code>component2<\/code>\u6765\u5c1d\u8bd5\u89e3\u51b3\u3002\u5177\u4f53\u53c2\u8003\u5e38\u89c1\u95ee\u9898<\/p>\n<\/blockquote>\n<h2>\u5e38\u89c1\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848<\/h2>\n<ol>\n<li>\u4f7f\u7528<code>@import<\/code>\u5f15\u5165\u5916\u90e8\u6837\u5f0f\u65e0\u6548\u6216\u8005\u62a5\u9519<\/li>\n<\/ol>\n<p><code>uni-app<\/code>\u5b98\u65b9\u7ed9\u51fa\u7684\u5f15\u7528\u5916\u90e8\u7684\u6837\u5f0f\u65b9\u5f0f\u4e3a<code>@import url(&#039;.\/common.scss&#039;)<\/code>\uff0c\u4f46\u5e94\u7528\u65f6\u53d1\u73b0\u7f16\u8bd1\u62a5\u9519\u6216\u8005\u4e0d\u751f\u6548\uff0c\u6b64\u65f6\u6539\u4e3a<code>@import &#039;.\/common.scss&#039;<\/code>\u5373\u53ef\u3002<\/p>\n<ol start=\"2\">\n<li><code>placeholder-class<\/code>\u4e0d\u8d77\u4f5c\u7528<\/li>\n<\/ol>\n<p>\u5728\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>placeholder-class<\/code>\u6765\u4fee\u6539\u9875\u9762\u7684\u8f93\u5165\u6846\u5360\u4f4d\u7b26\u7684\u6837\u8272\u3001\u5b57\u4f53\u5927\u5c0f\u7b49\u3002\u4f7f\u7528\u65f6\u4f1a\u53d1\u73b0\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u4e0d\u8d77\u4f5c\u7528\uff0c\u9875\u9762\u6837\u5f0f\u5982\u679c\u52a0\u4e86<code>scoped<\/code>\u5c5e\u6027\u4e5f\u4f1a\u4e0d\u8d77\u4f5c\u7528\u3002\u89e3\u51b3\u529e\u6cd5\u4e3a\uff1a<\/p>\n<ul>\n<li>\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u4e2d\u8f93\u5165\u6846\u4f7f\u7528<code>placeholder-style<\/code>\u66ff\u4ee3<\/li>\n<li>\u975e\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u4e2d\u7684\u8f93\u5165\u6846\u53ef\u4ee5\u5728<code>App.vue<\/code>\u5168\u5c40\u8bbe\u7f6e\uff0c\u5e76\u589e\u52a0<code>important<\/code>\u5173\u952e\u5b57\uff08\u767e\u5ea6\u5c0f\u7a0b\u5e8f\u65e0\u6548\uff09<\/li>\n<\/ul>\n<p><code>textarea<\/code>\u7684\u5904\u7406\u65b9\u6cd5\u4e00\u6837<\/p>\n<ol start=\"3\">\n<li><code>v-show<\/code>\u4e0d\u8d77\u4f5c\u7528<\/li>\n<\/ol>\n<p>\u4f7f\u7528<code>v-show<\/code>\u6307\u4ee4\u65f6\uff0c\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff08\u5982\u57fa\u4e8e\u6570\u7ec4\u7684<code>length<\/code>\u5c5e\u6027\u6765\u5224\u65ad\uff09\uff0c\u5728\u5c0f\u7a0b\u5e8f\u4e0b\u4e0d\u4f1a\u6b63\u5e38\u5de5\u4f5c\uff0c\u56e0\u4e3a\u5c0f\u7a0b\u5e8f\u7684<code>hidden<\/code>\u5c5e\u6027\u662f\u4e0d\u54cd\u5e94\u8be5\u53d8\u5316\u7684\uff0c\u53ef\u4f7f\u7528<code>v-if<\/code>\u4ee3\u66ff<\/p>\n<ol start=\"4\">\n<li><code>$refs<\/code>\u4e0d\u8d77\u4f5c\u7528<\/li>\n<\/ol>\n<p><code>uni-app<\/code>\u4e2d\u53ef\u4ee5\u4f7f\u7528<code>$refs<\/code>\u83b7\u53d6\u9875\u9762\u5bf9\u5e94\u7684\u7ec4\u4ef6\uff0c\u4f46\u662f\u524d\u63d0\u662f\u5728\u5c0f\u7a0b\u5e8f\u4e2d\u7ec4\u4ef6\u4e3a\u81ea\u5b9a\u4e49\u7ec4\u4ef6\uff0c\u539f\u751f\u7684\u7ec4\u4ef6\u65e0\u6cd5\u83b7\u53d6\u3002\u53e6\u5916\uff0c\u5728\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u4f7f\u7528<code>$refs<\/code>\u53ea\u80fd\u83b7\u53d6\u5230\u4e00\u7ea7\u7684\u7ec4\u4ef6\u5f15\u7528\uff0c\u5d4c\u5957\u7684\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u65e0\u6cd5\u83b7\u53d6\uff0c\u6709\u4e24\u79cd\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<p>\uff081\uff09\u53ef\u4ee5\u901a\u8fc7\u5d4c\u5957\u7684<code>$refs<\/code>\u6765\u83b7\u53d6\u5230\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-html\">&lt;template&gt;\n  &lt;popup ref=&quot;popup&quot;&gt;\n    &lt;view class=&quot;picker&quot;&gt;\n       &lt;region ref=&quot;picker&quot; \/&gt;\n    &lt;\/view&gt;\n  &lt;\/popup&gt;\n&lt;\/template&gt;<\/code><\/pre>\n<pre><code class=\"language-javascript\">mounted() {\n  this.popup = this.$refs.popup\n  \/\/ \u652f\u6301\u5b9d\u4e0d\u652f\u6301\u5d4c\u5957\u7684ref\n  this.picker = this.$refs.picker || this.popup.$refs.picker \n}<\/code><\/pre>\n<p>\uff082\uff09\u901a\u8fc7\u5c06\u652f\u4ed8\u5b9d\u7684\u7f16\u8bd1\u6a21\u5f0f\u6539\u4e3a<code>component2<\/code>\u7f16\u8bd1\u6a21\u5f0f\uff0c<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/opendocs.alipay.com\/mini\/framework\/custom-component-overview\" title=\"\u8be6\u60c5\u53ef\u67e5\u770b\u8fd9\u91cc\">\u8be6\u60c5\u53ef\u67e5\u770b\u8fd9\u91cc<\/a>\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-javascript\">&quot;mp-alipay&quot;: {\n  &quot;uniStatistics&quot;: {\n     &quot;enable&quot;: true\n  },\n  &quot;component2&quot;: true\n}<\/code><\/pre>\n<ol start=\"5\">\n<li>\u5305\u5927\u5c0f\u8fc7\u5927\uff0c\u65e0\u6cd5\u4e0a\u4f20<\/li>\n<\/ol>\n<p>\u5c0f\u7a0b\u5e8f\u5bf9\u5305\u7684\u5927\u5c0f\u6709\u9650\u5236\uff0c\u4e0d\u540c\u7684\u5c0f\u7a0b\u5e8f\u9650\u5236\u4e0d\u4e00\u6837\u3002\u4e00\u822c\u6211\u4eec\u4f1a\u91c7\u7528\u5206\u5305\u7684\u65b9\u5f0f\u6765\u5904\u7406\u3002\u4f46\u662f\u5728\u5f00\u53d1\u6a21\u5f0f\u4e0b\uff0c\u7531\u4e8e<code>uni-app<\/code>\u7f16\u8bd1\u65f6\u4f1a\u9644\u5e26<code>sourceMap<\/code>\uff0c\u5bfc\u81f4\u5206\u5305\u4e5f\u4f1a\u5f88\u5927\uff0c\u4ece\u800c\u8c03\u8bd5\u65f6\u65e0\u6cd5\u4e0a\u4f20\u5230\u771f\u673a\u8fdb\u884c\u8c03\u8bd5\uff0c\u5982QQ\u5c0f\u7a0b\u5e8f\u3002\u6b64\u65f6\uff0c\u6211\u4eec\u5728\u7f16\u8bd1\u65f6\u53ef\u4ee5\u9009\u62e9\u538b\u7f29\u4ee3\u7801\uff0c\u540c\u65f6\uff0c\u5728\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u8005\u5de5\u5177\u4e5f\u9009\u62e9\u4e0a\u4f20\u65f6\u81ea\u52a8\u538b\u7f29\u5373\u53ef\u3002\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u5728<code>HBuilderX<\/code>\u9009\u62e9<code>\u8fd0\u884c<\/code> &#8211; <code>\u8fd0\u884c\u5230\u5c0f\u7a0b\u5e8f\u6a21\u62df\u5668<\/code> &#8211; <code>\u52fe\u9009\u8fd0\u884c\u65f6\u538b\u7f29<\/code><\/li>\n<li>\u5728\u5f00\u53d1\u8005\u5de5\u5177\u9009\u62e9<code>\u8be6\u60c5<\/code> &#8211; <code>\u672c\u5730\u8bbe\u7f6e<\/code> &#8211; <code>\u52fe\u9009\u4e0a\u4f20\u4ee3\u7801\u65f6\u81ea\u52a8\u538b\u7f29\u6df7\u6dc6<\/code><\/li>\n<\/ul>\n<ol start=\"6\">\n<li><code>textarea<\/code>\u7a7f\u900f\u548c\u9519\u4f4d\u95ee\u9898<\/li>\n<\/ol>\n<p><code>textarea<\/code>\u7a7f\u900f\u4ee5\u53ca\u6eda\u52a8\u7684\u95ee\u9898\u5c5e\u4e8e\u5c0f\u7a0b\u5e8f\u7684\u95ee\u9898\u3002<code>textarea<\/code>\u5c5e\u4e8e\u539f\u751f\u7ec4\u4ef6\uff0c\u5728\u653e\u7f6e\u5230\u5177\u6709<code>fixed<\/code>\u5b9a\u4f4d\u7684\u5f39\u7a97\u4e4b\u7c7b\u7684\u5bb9\u5668\u65f6\u5c31\u4f1a\u51fa\u73b0\u8fd9\u6837\u90a3\u6837\u7684\u95ee\u9898\u3002\u901a\u5e38\u6211\u4eec\u6709\u4e24\u79cd\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<ul>\n<li>\u5f39\u7a97\u5c55\u793a\u524d\u5148\u9690\u85cf\u6389<code>textarea<\/code>\u6216\u8005\u4f7f\u7528\u5176\u4ed6\u7684\u5143\u7d20\u4ee3\u66ff\uff0c\u5f39\u7a97\u5c55\u793a\u5b8c\u6bd5\u540e\u518d\u663e\u793a<code>textarea<\/code>\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u5f39\u7a97\u4f4d\u7f6e\u9519\u4f4d\u7684\u95ee\u9898<\/li>\n<li>\u8f93\u5165\u7ec4\u4ef6\u5931\u53bb\u7126\u70b9\u65f6\u66ff\u6362\u4e3a<code>view<\/code>\u7ec4\u4ef6\uff0c\u83b7\u5f97\u7126\u70b9\u65f6\u6062\u590d\u4e3a<code>textarea<\/code>\u7ec4\u4ef6<\/li>\n<\/ul>\n<ol start=\"7\">\n<li>\u63d0\u793a\u5b50\u7ec4\u4ef6\u4e0d\u80fd\u4fee\u6539\u7236\u7ec4\u4ef6\u7684<code>props<\/code><\/li>\n<\/ol>\n<p>\u7f16\u8bd1\u540e\uff0c\u5728\u652f\u4ed8\u5b9d\u4e0b\u4f1a\u63d0\u793a\u5b50\u7ec4\u4ef6\u4e0d\u80fd\u4fee\u6539\u7236\u7ec4\u4ef6\u7684<code>props<\/code>\uff0c\u5982<code>Avoid mutating a prop directly since the value will be overwritten ....Prop being mutated &quot;value&quot;<\/code>\u3002\u8fd9\u4e2a\u9519\u8bef\u5c31\u7b97\u662f\u6ca1\u6709\u5728\u5b50\u7ec4\u4ef6\u4fee\u6539\u7236\u7ec4\u4ef6\u7684\u5c5e\u6027\u4e5f\u4f1a\u62a5\u51fa\u6765\u3002\u539f\u56e0\u662f\u652f\u4ed8\u5b9d\u4ee5\u53ca\u9489\u9489\u7b49\u652f\u4ed8\u5b9d\u7cfb\u7684\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u8005\u5de5\u5177\u7684\u4e00\u4e2a<code>bug<\/code>\uff0c\u5b9e\u9645\u4e0a\u7ec4\u4ef6\u662f\u6b63\u5e38\u5de5\u4f5c\u7684\uff0c\u4f46\u662f\u4f1a\u9519\u8bef\u7684\u62a5\u51fa\u8fd9\u6761\u4fe1\u606f\uff0c\u8fd9\u4e2a\u5ffd\u7565\u5373\u53ef\uff0c\u540e\u7eed\u7248\u672c\u5b98\u65b9\u5e94\u8be5\u4f1a\u4fee\u590d\u3002<\/p>\n<ol start=\"8\">\n<li><code>inject\/provide<\/code>\u4e0d\u8d77\u4f5c\u7528<\/li>\n<\/ol>\n<p>\u5728\u81ea\u5df1\u5199\u4e00\u4e9b\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u6216\u8005\u4f7f\u7528<code>uni-ui<\/code>\u6269\u5c55\u7ec4\u4ef6\uff08\u5982<code>swipe-action<\/code>\uff09\u7684\u65f6\u5019\uff0c\u5728\u652f\u4ed8\u5b9d\u4e0b\u4f1a\u62a5<code>Injection &quot;xxxx&quot; not found<\/code>\uff0c\u5982<code>Injection &quot;swipeaction&quot; not found<\/code>\u7684\u9519\u8bef\uff0c\u8fd9\u4e2a\u662f\u56e0\u4e3a\u6ca1\u6709\u5f00\u542f<code>component2<\/code>\u7f16\u8bd1\u6a21\u5f0f\u7684\u539f\u56e0\uff0c\u5f00\u542f\u4e86\u5373\u53ef\u89e3\u51b3\u3002\u53c2\u8003\u5e38\u89c1\u95ee\u9898\u7b2c4\u70b9<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u591a\u7aef\u6784\u5efa\u7684\u89e3\u51b3\u65b9\u6848\u8ba9\u6211\u4eec\u5199\u4e00\u5957\u4ee3\u7801\u8fd0\u884c\u5230\u591a\u4e2a\u7aef\u6210\u4e3a\u4e86\u53ef\u80fd\uff0c\u5927\u5927\u51cf\u4f4e\u4e86\u5f00\u53d1\u8005\u8d1f\u62c5\uff0c\u4e5f\u8282\u7701\u4e86\u4f01\u4e1a\u7684\u8d44\u6e90\u3002\u4f46\u7531\u4e8e\u5e73\u53f0\u4e0d\u53ef\u907f\u514d\u7684\u5dee\u5f02\u6027\uff0c\u4ecd\u7136\u5b58\u5728\u4e0d\u5c11\u95ee\u9898\u9700\u8981\u5f00\u53d1\u8005\u81ea\u884c\u53bb\u89e3\u51b3\u3002\u53e6\u5916\uff0c\u5feb\u5e94\u7528\u76ee\u524d\u652f\u6301\u7684\u7a0b\u5ea6\u975e\u5e38\u5f31\uff0c<code>uni-app<\/code>\u5b98\u65b9\u5df2\u7ecf\u652f\u6301\u4e86\u57fa\u4e8e<code>webview<\/code>\u6e32\u67d3\u7684\u5feb\u5e94\u7528\uff0c\u4f46\u662f\u4f9d\u7136\u5b58\u5728\u4e0d\u5c11\u95ee\u9898\uff0c\u540c\u65f6\uff0c\u8be5\u6a21\u5f0f\u76ee\u524d\u4ec5\u534e\u4e3a\/OPPO\/Vivo\u652f\u6301\uff0c\u5176\u4ed6\u8054\u76df\u5382\u5546\u5e76\u4e0d\u652f\u6301\u3002\u57fa\u4e8e\u539f\u751f\u5feb\u5e94\u7528\u6a21\u5f0f\u7684\u6e32\u67d3\uff0c<code>uni-app<\/code>\u8ba1\u5212\u7531\u793e\u533a\u6765\u5b9e\u73b0\uff0c\u76ee\u524d\u4ecd\u65e7\u6ca1\u6709\u597d\u7684\u89e3\u51b3\u65b9\u6848\u3002\u800c\u4ece<code>Taro<\/code>\u5b98\u65b9\u6587\u6863\u6765\u770b\uff0c<code>Taro<\/code>\u7684\u652f\u6301\u5e94\u8be5\u4e5f\u6bd4\u8f83\u6709\u9650\uff08\u672a\u6d4b\u8bd5\uff0c\u6b22\u8fce\u544a\u77e5\u6d4b\u8bc4\u7ed3\u679c\uff09\uff0c\u53ef\u80fd\u4e0d\u80fd\u7528\u4e8e\u6bd4\u8f83\u590d\u6742\u7684\u5e94\u7528\u3002<\/p>\n<p>\u65e0\u8bba\u662f<code>Taro<\/code>\u4e5f\u597d\uff0c<code>uni-app<\/code>\u4e5f\u7f62\uff0c\u76ee\u524d\u793e\u533a\u90fd\u5728\u4e0d\u65ad\u7684\u5b8c\u5584\u548c\u58ee\u5927\u3002\u76f8\u4fe1\u5728\u56fd\u5185\u5c0f\u7a0b\u5e8f\u5382\u5546\u3001\u5feb\u5e94\u7528\u8054\u76df\u4ee5\u53ca\u793e\u533a\u7684\u52aa\u529b\u4e0b\uff0c\u591a\u7aef\u6784\u5efa\u7684\u65b9\u6848\u4f1a\u65e5\u8d8b\u6210\u719f\uff0c\u5e76\u80fd\u591f\u5f62\u6210\u4e00\u5957\u66f4\u52a0\u7edf\u4e00\u7684\u3001\u4f18\u79c0\u4e2a\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p>\u6e90\u7801\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/prianyu\/uniapp\">https:\/\/github.com\/prianyu\/uniapp<\/a><br \/>\n\u672c\u6587\u8f6c\u8f7d\u81f3\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/juejin.im\/post\/6868484714979098638\">https:\/\/juejin.im\/post\/6868484714979098638<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u5c0f\u7a0b\u5e8f\u5177\u6709\u8de8\u5e73\u53f0\u3001\u4f53\u9a8c\u597d\u3001\u9ad8\u7075\u6d3b\u6027\u4ee5\u53ca\u5373\u7528\u5373\u8d70\u3001\u65e0\u9700\u4e0b\u8f7d\u5b89\u88c5\u8bf8\u591a\u4f18\u52bf\u3002\u968f\u7740\u5fae\u4fe1\u56e2\u961f\u63a8\u51fa\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\uff0c\u56fd\u5185\u5404 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"class_list":["post-1312","post","type-post","status-publish","format-standard","hentry","category-uni-app"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1312","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=1312"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1312\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}