{"id":44279,"date":"2025-06-18T09:33:42","date_gmt":"2025-06-18T01:33:42","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/44279.html"},"modified":"2025-06-18T09:33:42","modified_gmt":"2025-06-18T01:33:42","slug":"uniapp%e7%bd%91%e7%bb%9c%e8%af%b7%e6%b1%82%e5%85%a8%e9%9d%a2%e6%8c%87%e5%8d%97%ef%bc%9a%e4%bb%8e%e5%9f%ba%e7%a1%80%e5%88%b0%e9%ab%98%e7%ba%a7%e5%b0%81%e8%a3%85","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/44279.html","title":{"rendered":"Uniapp\u7f51\u7edc\u8bf7\u6c42\u5168\u9762\u6307\u5357\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5c01\u88c5"},"content":{"rendered":"<p>\u5728\u79fb\u52a8\u5e94\u7528\u548c\u8de8\u5e73\u53f0\u5f00\u53d1\u4e2d&#xff0c;\u7f51\u7edc\u8bf7\u6c42\u662f\u6700\u57fa\u7840\u4e5f\u662f\u6700\u91cd\u8981\u7684\u529f\u80fd\u4e4b\u4e00\u3002Uniapp\u4f5c\u4e3a\u4e00\u6b3e\u6d41\u884c\u7684\u8de8\u5e73\u53f0\u5f00\u53d1\u6846\u67b6&#xff0c;\u63d0\u4f9b\u4e86\u5f3a\u5927\u800c\u7075\u6d3b\u7684\u7f51\u7edc\u8bf7\u6c42API\u2014\u2014uni.request\u3002\u672c\u6587\u5c06\u5168\u9762\u4ecb\u7ecdUniapp\u7f51\u7edc\u8bf7\u6c42\u7684\u5404\u4e2a\u65b9\u9762&#xff0c;\u5305\u62ec\u57fa\u7840\u4f7f\u7528\u3001\u53c2\u6570\u8be6\u89e3\u3001\u9519\u8bef\u5904\u7406\u3001\u6027\u80fd\u4f18\u5316\u4ee5\u53ca\u9ad8\u7ea7\u5c01\u88c5\u6280\u5de7&#xff0c;\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u5065\u58ee\u7684\u7f51\u7edc\u8bf7\u6c42\u4f53\u7cfb\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250618013338-68521772ec78c.png\" \/><\/p>\n<h3>\u4e00\u3001Uniapp\u7f51\u7edc\u8bf7\u6c42\u6982\u8ff0<\/h3>\n<p>Uniapp\u7684uni.request\u662f\u4e00\u4e2a\u57fa\u4e8ePromise\u98ce\u683c\u7684HTTP\u5ba2\u6237\u7aef&#xff0c;\u5b83\u5c01\u88c5\u4e86\u5404\u5e73\u53f0&#xff08;\u5c0f\u7a0b\u5e8f\u3001H5\u3001App&#xff09;\u7684\u7f51\u7edc\u8bf7\u6c42\u80fd\u529b&#xff0c;\u63d0\u4f9b\u4e86\u4e00\u81f4\u7684API\u63a5\u53e3\u3002\u4e0e\u539f\u751fJavaScript\u7684fetch\u6216jQuery\u7684$.ajax\u76f8\u6bd4&#xff0c;uni.request\u5177\u6709\u4ee5\u4e0b\u7279\u70b9&#xff1a;<\/p>\n<li>\n<p>\u8de8\u5e73\u53f0\u4e00\u81f4\u6027&#xff1a;\u5728\u4e0d\u540c\u5e73\u53f0\u4e0a\u8868\u73b0\u4e00\u81f4&#xff0c;\u5f00\u53d1\u8005\u65e0\u9700\u5173\u5fc3\u5e95\u5c42\u5b9e\u73b0\u5dee\u5f02<\/p>\n<\/li>\n<li>\n<p>\u7b80\u5355\u6613\u7528&#xff1a;\u57fa\u4e8e\u914d\u7f6e\u5bf9\u8c61\u7684API\u8bbe\u8ba1&#xff0c;\u5b66\u4e60\u6210\u672c\u4f4e<\/p>\n<\/li>\n<li>\n<p>\u529f\u80fd\u5168\u9762&#xff1a;\u652f\u6301GET\u3001POST\u7b49\u591a\u79cdHTTP\u65b9\u6cd5&#xff0c;\u53ef\u8bbe\u7f6e\u8d85\u65f6\u3001\u8bf7\u6c42\u5934\u7b49<\/p>\n<\/li>\n<li>\n<p>\u6269\u5c55\u6027\u5f3a&#xff1a;\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c01\u88c5\u548c\u6269\u5c55&#xff0c;\u652f\u6301\u62e6\u622a\u5668\u7b49\u9ad8\u7ea7\u529f\u80fd<\/p>\n<\/li>\n<p>\u5728Uniapp\u751f\u6001\u4e2d&#xff0c;\u7f51\u7edc\u8bf7\u6c42\u662f\u4e0e\u540e\u7aef\u4ea4\u4e92\u7684\u4e3b\u8981\u65b9\u5f0f&#xff0c;\u638c\u63e1uni.request\u7684\u4f7f\u7528\u6280\u5de7\u5bf9\u4e8e\u5f00\u53d1\u9ad8\u8d28\u91cf\u5e94\u7528\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<h3>\u4e8c\u3001uni.request\u57fa\u7840\u4f7f\u7528<\/h3>\n<h4>2.1 \u57fa\u672c\u8bf7\u6c42\u793a\u4f8b<\/h4>\n<p>\u8ba9\u6211\u4eec\u4ece\u4e00\u4e2a\u6700\u7b80\u5355\u7684GET\u8bf7\u6c42\u5f00\u59cb&#xff1a;<\/p>\n<p>uni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/data&#039;,<br \/>\n  success: (res) &#061;&gt; {<br \/>\n    console.log(&#039;\u8bf7\u6c42\u6210\u529f:&#039;, res.data);<br \/>\n  },<br \/>\n  fail: (err) &#061;&gt; {<br \/>\n    console.error(&#039;\u8bf7\u6c42\u5931\u8d25:&#039;, err);<br \/>\n  }<br \/>\n}); <\/p>\n<p>\u8fd9\u4e2a\u4f8b\u5b50\u5c55\u793a\u4e86uni.request\u6700\u57fa\u672c\u7684\u4f7f\u7528\u65b9\u5f0f&#xff1a;\u4f20\u5165\u4e00\u4e2a\u914d\u7f6e\u5bf9\u8c61&#xff0c;\u5305\u542b\u8bf7\u6c42URL\u548c\u6210\u529f\/\u5931\u8d25\u56de\u8c03\u51fd\u6570\u3002<\/p>\n<h4>2.2 \u8bf7\u6c42\u65b9\u6cd5\u914d\u7f6e<\/h4>\n<p>uni.request\u652f\u6301\u6240\u6709\u5e38\u89c1\u7684HTTP\u65b9\u6cd5&#xff1a;<\/p>\n<p>\/\/ GET\u8bf7\u6c42<br \/>\nuni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/data&#039;,<br \/>\n  method: &#039;GET&#039;<br \/>\n});<\/p>\n<p>\/\/ POST\u8bf7\u6c42<br \/>\nuni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/create&#039;,<br \/>\n  method: &#039;POST&#039;,<br \/>\n  data: { name: &#039;\u4ea7\u54c1\u540d\u79f0&#039;, price: 99 }<br \/>\n});<\/p>\n<p>\/\/ PUT\u8bf7\u6c42<br \/>\nuni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/update\/1&#039;,<br \/>\n  method: &#039;PUT&#039;,<br \/>\n  data: { price: 109 }<br \/>\n});<\/p>\n<p>\/\/ DELETE\u8bf7\u6c42<br \/>\nuni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/delete\/1&#039;,<br \/>\n  method: &#039;DELETE&#039;<br \/>\n}); <\/p>\n<h4>2.3 \u8bf7\u6c42\u53c2\u6570\u4f20\u9012<\/h4>\n<p>\u8bf7\u6c42\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7data\u5c5e\u6027\u4f20\u9012&#xff0c;Uniapp\u4f1a\u6839\u636e\u8bf7\u6c42\u65b9\u6cd5\u81ea\u52a8\u5904\u7406\u53c2\u6570\u4f4d\u7f6e&#xff1a;<\/p>\n<p>\/\/ GET\u8bf7\u6c42\u53c2\u6570\u4f1a\u9644\u52a0\u5728URL\u540e<br \/>\nuni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/search&#039;,<br \/>\n  data: { keyword: &#039;\u624b\u673a&#039;, page: 1 }<br \/>\n});<\/p>\n<p>\/\/ POST\u8bf7\u6c42\u53c2\u6570\u4f1a\u653e\u5728\u8bf7\u6c42\u4f53\u4e2d<br \/>\nuni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/login&#039;,<br \/>\n  method: &#039;POST&#039;,<br \/>\n  data: { username: &#039;admin&#039;, password: &#039;123456&#039; }<br \/>\n}); <\/p>\n<h3>\u4e09\u3001\u8bf7\u6c42\u914d\u7f6e\u8be6\u89e3<\/h3>\n<p>uni.request\u63a5\u53d7\u4e00\u4e2a\u914d\u7f6e\u5bf9\u8c61&#xff0c;\u5305\u542b\u4e30\u5bcc\u7684\u914d\u7f6e\u9009\u9879\u3002\u4ee5\u4e0b\u662f\u4e3b\u8981\u914d\u7f6e\u9879\u7684\u8be6\u7ec6\u8bf4\u660e&#xff1a;<\/p>\n<h4>3.1 \u6838\u5fc3\u914d\u7f6e\u9879<\/h4>\n<table>\n<tr>\u914d\u7f6e\u9879\u7c7b\u578b\u9ed8\u8ba4\u503c\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>url<\/td>\n<td>String<\/td>\n<td>&#8211;<\/td>\n<td>\u8bf7\u6c42\u5730\u5740&#xff0c;\u53ef\u4ee5\u662f\u76f8\u5bf9\u8def\u5f84\u6216\u7edd\u5bf9\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td>method<\/td>\n<td>String<\/td>\n<td>&#039;GET&#039;<\/td>\n<td>HTTP\u65b9\u6cd5&#xff1a;GET\/POST\/PUT\/DELETE\u7b49<\/td>\n<\/tr>\n<tr>\n<td>data<\/td>\n<td>Object\/String\/ArrayBuffer<\/td>\n<td>&#8211;<\/td>\n<td>\u8bf7\u6c42\u53c2\u6570&#xff0c;\u6839\u636emethod\u4e0d\u540c\u5904\u7406\u65b9\u5f0f\u4e0d\u540c<\/td>\n<\/tr>\n<tr>\n<td>header<\/td>\n<td>Object<\/td>\n<td>{&#039;Content-Type&#039;: &#039;application\/json&#039;}<\/td>\n<td>\u8bf7\u6c42\u5934\u8bbe\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>timeout<\/td>\n<td>Number<\/td>\n<td>60000<\/td>\n<td>\u8bf7\u6c42\u8d85\u65f6\u65f6\u95f4&#xff0c;\u5355\u4f4d\u6beb\u79d2<\/td>\n<\/tr>\n<tr>\n<td>dataType<\/td>\n<td>String<\/td>\n<td>&#039;json&#039;<\/td>\n<td>\u8fd4\u56de\u6570\u636e\u683c\u5f0f&#xff0c;\u53ef\u9009json\/text<\/td>\n<\/tr>\n<tr>\n<td>responseType<\/td>\n<td>String<\/td>\n<td>&#039;text&#039;<\/td>\n<td>\u54cd\u5e94\u6570\u636e\u7c7b\u578b&#xff0c;\u53ef\u9009text\/arraybuffer<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3.2 \u8bf7\u6c42\u5934\u8bbe\u7f6e<\/h4>\n<p>\u8bf7\u6c42\u5934\u662f\u7f51\u7edc\u8bf7\u6c42\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u90e8\u5206&#xff0c;\u5e38\u7528\u4e8e\u4f20\u9012\u8ba4\u8bc1\u4fe1\u606f\u3001\u5185\u5bb9\u7c7b\u578b\u7b49&#xff1a;<\/p>\n<p>uni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/protected&#039;,<br \/>\n  header: {<br \/>\n    &#039;Content-Type&#039;: &#039;application\/json&#039;,<br \/>\n    &#039;Authorization&#039;: &#039;Bearer &#039; &#043; token,<br \/>\n    &#039;X-Custom-Header&#039;: &#039;custom-value&#039;<br \/>\n  }<br \/>\n}); <\/p>\n<p>\u5e38\u89c1\u7684\u8bf7\u6c42\u5934\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\n<p>Content-Type: \u8bf7\u6c42\u4f53\u7c7b\u578b&#xff0c;\u5982application\/json\u3001application\/x-www-form-urlencoded\u7b49<\/p>\n<\/li>\n<li>\n<p>Authorization: \u8ba4\u8bc1\u4ee4\u724c&#xff0c;\u901a\u5e38\u7528\u4e8eJWT\u7b49\u8ba4\u8bc1\u65b9\u6848<\/p>\n<\/li>\n<li>\n<p>Accept: \u544a\u8bc9\u670d\u52a1\u5668\u5ba2\u6237\u7aef\u80fd\u5904\u7406\u7684\u54cd\u5e94\u7c7b\u578b<\/p>\n<\/li>\n<\/ul>\n<h4>3.3 \u8d85\u65f6\u8bbe\u7f6e<\/h4>\n<p>\u7f51\u7edc\u8bf7\u6c42\u53ef\u80fd\u4f1a\u56e0\u4e3a\u5404\u79cd\u539f\u56e0\u8d85\u65f6&#xff0c;\u5408\u7406\u7684\u8d85\u65f6\u8bbe\u7f6e\u53ef\u4ee5\u63d0\u5347\u7528\u6237\u4f53\u9a8c&#xff1a;<\/p>\n<p>uni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/data&#039;,<br \/>\n  timeout: 10000, \/\/ 10\u79d2\u8d85\u65f6<br \/>\n  success() {},<br \/>\n  fail(err) {<br \/>\n    if (err.errMsg.includes(&#039;timeout&#039;)) {<br \/>\n      uni.showToast({ title: &#039;\u8bf7\u6c42\u8d85\u65f6&#039;, icon: &#039;none&#039; });<br \/>\n    }<br \/>\n  }<br \/>\n}); <\/p>\n<p>\u8d85\u65f6\u8bbe\u7f6e\u9700\u8981\u8003\u8651\u4e1a\u52a1\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u666e\u901a\u6570\u636e\u8bf7\u6c42&#xff1a;5-10\u79d2<\/p>\n<\/li>\n<li>\n<p>\u6587\u4ef6\u4e0a\u4f20&#xff1a;30-60\u79d2<\/p>\n<\/li>\n<li>\n<p>\u5173\u952e\u4e1a\u52a1\u8bf7\u6c42&#xff1a;\u9002\u5f53\u5ef6\u957f\u4f46\u8981\u6709\u8d85\u65f6\u63d0\u793a<\/p>\n<\/li>\n<\/ul>\n<h3>\u56db\u3001\u54cd\u5e94\u5904\u7406\u4e0e\u9519\u8bef\u5904\u7406<\/h3>\n<h4>4.1 \u54cd\u5e94\u6570\u636e\u7ed3\u6784<\/h4>\n<p>uni.request\u7684\u6210\u529f\u56de\u8c03\u4f1a\u6536\u5230\u4e00\u4e2a\u54cd\u5e94\u5bf9\u8c61&#xff0c;\u5305\u542b\u4ee5\u4e0b\u5c5e\u6027&#xff1a;<\/p>\n<p>{<br \/>\n  data: {}, \/\/ \u54cd\u5e94\u6570\u636e&#xff0c;\u7c7b\u578b\u53d6\u51b3\u4e8edataType\u914d\u7f6e<br \/>\n  statusCode: 200, \/\/ HTTP\u72b6\u6001\u7801<br \/>\n  header: {}, \/\/ \u54cd\u5e94\u5934<br \/>\n  cookies: [] \/\/ \u670d\u52a1\u5668\u8fd4\u56de\u7684cookies<br \/>\n} <\/p>\n<h4>4.2 \u72b6\u6001\u7801\u5904\u7406<\/h4>\n<p>\u5408\u7406\u7684\u72b6\u6001\u7801\u5904\u7406\u662f\u5065\u58ee\u5e94\u7528\u7684\u57fa\u7840&#xff1a;<\/p>\n<p>uni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/data&#039;,<br \/>\n  success: (res) &#061;&gt; {<br \/>\n    switch (res.statusCode) {<br \/>\n      case 200:<br \/>\n        \/\/ \u6210\u529f\u5904\u7406<br \/>\n        break;<br \/>\n      case 401:<br \/>\n        \/\/ \u672a\u6388\u6743&#xff0c;\u8df3\u8f6c\u767b\u5f55<br \/>\n        uni.navigateTo({ url: &#039;\/pages\/login\/login&#039; });<br \/>\n        break;<br \/>\n      case 404:<br \/>\n        \/\/ \u8d44\u6e90\u4e0d\u5b58\u5728<br \/>\n        break;<br \/>\n      case 500:<br \/>\n        \/\/ \u670d\u52a1\u5668\u9519\u8bef<br \/>\n        break;<br \/>\n      default:<br \/>\n        \/\/ \u5176\u4ed6\u72b6\u6001\u7801<br \/>\n    }<br \/>\n  }<br \/>\n}); <\/p>\n<h4>4.3 \u9519\u8bef\u5904\u7406<\/h4>\n<p>\u7f51\u7edc\u8bf7\u6c42\u53ef\u80fd\u56e0\u591a\u79cd\u539f\u56e0\u5931\u8d25&#xff0c;\u5b8c\u5584\u7684\u9519\u8bef\u5904\u7406\u5fc5\u4e0d\u53ef\u5c11&#xff1a;<\/p>\n<p>uni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/data&#039;,<br \/>\n  fail: (err) &#061;&gt; {<br \/>\n    console.error(&#039;\u8bf7\u6c42\u5931\u8d25:&#039;, err);<\/p>\n<p>    if (err.errMsg.includes(&#039;timeout&#039;)) {<br \/>\n      uni.showToast({ title: &#039;\u8bf7\u6c42\u8d85\u65f6&#xff0c;\u8bf7\u91cd\u8bd5&#039;, icon: &#039;none&#039; });<br \/>\n    } else if (err.errMsg.includes(&#039;fail&#039;)) {<br \/>\n      uni.showToast({ title: &#039;\u7f51\u7edc\u9519\u8bef&#xff0c;\u8bf7\u68c0\u67e5\u7f51\u7edc&#039;, icon: &#039;none&#039; });<br \/>\n    }<br \/>\n  }<br \/>\n}); <\/p>\n<p>\u5e38\u89c1\u7684\u9519\u8bef\u7c7b\u578b\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u7f51\u7edc\u4e0d\u53ef\u7528<\/p>\n<\/li>\n<li>\n<p>\u8bf7\u6c42\u8d85\u65f6<\/p>\n<\/li>\n<li>\n<p>SSL\u8bc1\u4e66\u9519\u8bef&#xff08;App\u7aef&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u57df\u540d\u672a\u914d\u7f6e&#xff08;\u5c0f\u7a0b\u5e8f\u7aef&#xff09;<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e94\u3001\u9ad8\u7ea7\u5c01\u88c5\u4e0e\u5b9e\u8df5<\/h3>\n<h4>5.1 Promise\u5c01\u88c5<\/h4>\n<p>\u56de\u8c03\u65b9\u5f0f\u5728\u73b0\u4ee3\u524d\u7aef\u5f00\u53d1\u4e2d\u5df2\u7ecf\u4e0d\u63a8\u8350\u4f7f\u7528&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5c06uni.request\u5c01\u88c5\u4e3aPromise&#xff1a;<\/p>\n<p>function request(options) {<br \/>\n  return new Promise((resolve, reject) &#061;&gt; {<br \/>\n    uni.request({<br \/>\n      &#8230;options,<br \/>\n      success: (res) &#061;&gt; {<br \/>\n        if (res.statusCode &gt;&#061; 200 &amp;&amp; res.statusCode &lt; 300) {<br \/>\n          resolve(res.data);<br \/>\n        } else {<br \/>\n          reject(new Error(&#096;\u8bf7\u6c42\u5931\u8d25&#xff0c;\u72b6\u6001\u7801&#xff1a;${res.statusCode}&#096;));<br \/>\n        }<br \/>\n      },<br \/>\n      fail: (err) &#061;&gt; {<br \/>\n        reject(err);<br \/>\n      }<br \/>\n    });<br \/>\n  });<br \/>\n}<\/p>\n<p>\/\/ \u4f7f\u7528\u793a\u4f8b<br \/>\nrequest({<br \/>\n  url: &#039;https:\/\/api.example.com\/data&#039;<br \/>\n}).then(data &#061;&gt; {<br \/>\n  console.log(data);<br \/>\n}).catch(err &#061;&gt; {<br \/>\n  console.error(err);<br \/>\n}); <\/p>\n<h4>5.2 \u5b8c\u6574\u8bf7\u6c42\u5c01\u88c5<\/h4>\n<p>\u4e00\u4e2a\u5b8c\u6574\u7684\u8bf7\u6c42\u5c01\u88c5\u901a\u5e38\u5305\u62ec\u4ee5\u4e0b\u529f\u80fd&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u57fa\u7840URL\u914d\u7f6e<\/p>\n<\/li>\n<li>\n<p>\u8bf7\u6c42\u62e6\u622a&#xff08;\u5982\u6dfb\u52a0token&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u54cd\u5e94\u62e6\u622a&#xff08;\u5982\u7edf\u4e00\u9519\u8bef\u5904\u7406&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u8bf7\u6c42\u53d6\u6d88<\/p>\n<\/li>\n<li>\n<p>\u8bf7\u6c42\u91cd\u8bd5<\/p>\n<\/li>\n<\/ul>\n<p>const http &#061; {<br \/>\n  config: {<br \/>\n    baseUrl: &#039;https:\/\/api.example.com&#039;,<br \/>\n    timeout: 10000,<br \/>\n    header: {<br \/>\n      &#039;Content-Type&#039;: &#039;application\/json&#039;<br \/>\n    }<br \/>\n  },<\/p>\n<p>  interceptors: {<br \/>\n    request: null,<br \/>\n    response: null<br \/>\n  },<\/p>\n<p>  request(options) {<br \/>\n    \/\/ \u5408\u5e76\u914d\u7f6e<br \/>\n    options &#061; { &#8230;this.config, &#8230;options };<br \/>\n    options.url &#061; options.baseUrl &#043; options.url;<\/p>\n<p>    \/\/ \u8bf7\u6c42\u62e6\u622a<br \/>\n    if (this.interceptors.request) {<br \/>\n      options &#061; this.interceptors.request(options);<br \/>\n    }<\/p>\n<p>    return new Promise((resolve, reject) &#061;&gt; {<br \/>\n      options.success &#061; (res) &#061;&gt; {<br \/>\n        \/\/ \u54cd\u5e94\u62e6\u622a<br \/>\n        if (this.interceptors.response) {<br \/>\n          res &#061; this.interceptors.response(res);<br \/>\n        }<br \/>\n        resolve(res.data);<br \/>\n      };<\/p>\n<p>      options.fail &#061; (err) &#061;&gt; {<br \/>\n        reject(err);<br \/>\n      };<\/p>\n<p>      uni.request(options);<br \/>\n    });<br \/>\n  }<br \/>\n};<\/p>\n<p>\/\/ \u6dfb\u52a0\u8bf7\u6c42\u62e6\u622a\u5668<br \/>\nhttp.interceptors.request &#061; (config) &#061;&gt; {<br \/>\n  const token &#061; uni.getStorageSync(&#039;token&#039;);<br \/>\n  if (token) {<br \/>\n    config.header.Authorization &#061; &#096;Bearer ${token}&#096;;<br \/>\n  }<br \/>\n  return config;<br \/>\n};<\/p>\n<p>\/\/ \u6dfb\u52a0\u54cd\u5e94\u62e6\u622a\u5668<br \/>\nhttp.interceptors.response &#061; (response) &#061;&gt; {<br \/>\n  if (response.statusCode &#061;&#061;&#061; 401) {<br \/>\n    uni.navigateTo({ url: &#039;\/pages\/login\/login&#039; });<br \/>\n    throw new Error(&#039;\u672a\u6388\u6743&#xff0c;\u8bf7\u91cd\u65b0\u767b\u5f55&#039;);<br \/>\n  }<br \/>\n  return response;<br \/>\n};<\/p>\n<p>\/\/ \u4f7f\u7528\u793a\u4f8b<br \/>\nhttp.request({<br \/>\n  url: &#039;\/user\/info&#039;,<br \/>\n  method: &#039;GET&#039;<br \/>\n}).then(data &#061;&gt; {<br \/>\n  console.log(data);<br \/>\n}).catch(err &#061;&gt; {<br \/>\n  console.error(err);<br \/>\n}); <\/p>\n<h4>5.3 \u6587\u4ef6\u4e0a\u4f20\u4e0e\u4e0b\u8f7d<\/h4>\n<p>\u9664\u4e86\u666e\u901a\u7684\u8bf7\u6c42&#xff0c;Uniapp\u8fd8\u63d0\u4f9b\u4e86\u4e13\u95e8\u7684\u6587\u4ef6\u4e0a\u4f20\u548c\u4e0b\u8f7dAPI&#xff1a;<\/p>\n<p>\/\/ \u6587\u4ef6\u4e0a\u4f20<br \/>\nuni.chooseImage({<br \/>\n  success: (res) &#061;&gt; {<br \/>\n    const tempFilePaths &#061; res.tempFilePaths;<br \/>\n    uni.uploadFile({<br \/>\n      url: &#039;https:\/\/api.example.com\/upload&#039;,<br \/>\n      filePath: tempFilePaths[0],<br \/>\n      name: &#039;file&#039;,<br \/>\n      formData: {<br \/>\n        &#039;description&#039;: &#039;\u56fe\u7247\u63cf\u8ff0&#039;<br \/>\n      },<br \/>\n      success: (uploadRes) &#061;&gt; {<br \/>\n        console.log(uploadRes.data);<br \/>\n      }<br \/>\n    });<br \/>\n  }<br \/>\n});<\/p>\n<p>\/\/ \u6587\u4ef6\u4e0b\u8f7d<br \/>\nuni.downloadFile({<br \/>\n  url: &#039;https:\/\/example.com\/file.pdf&#039;,<br \/>\n  success: (res) &#061;&gt; {<br \/>\n    if (res.statusCode &#061;&#061;&#061; 200) {<br \/>\n      const filePath &#061; res.tempFilePath;<br \/>\n      uni.openDocument({<br \/>\n        filePath: filePath,<br \/>\n        fileType: &#039;pdf&#039;<br \/>\n      });<br \/>\n    }<br \/>\n  }<br \/>\n}); <\/p>\n<h3>\u516d\u3001\u8de8\u5e73\u53f0\u6ce8\u610f\u4e8b\u9879<\/h3>\n<p>Uniapp\u867d\u7136\u63d0\u4f9b\u4e86\u8de8\u5e73\u53f0\u7684\u7f51\u7edc\u8bf7\u6c42API&#xff0c;\u4f46\u5728\u4e0d\u540c\u5e73\u53f0\u4e0a\u4ecd\u6709\u4e00\u4e9b\u5dee\u5f02\u9700\u8981\u6ce8\u610f&#xff1a;<\/p>\n<h4>6.1 \u5c0f\u7a0b\u5e8f\u5e73\u53f0<\/h4>\n<li>\n<p>\u57df\u540d\u9650\u5236&#xff1a;\u5fc5\u987b\u5728\u5c0f\u7a0b\u5e8f\u540e\u53f0\u914d\u7f6e\u5408\u6cd5\u57df\u540d<\/p>\n<\/li>\n<li>\n<p>HTTPS\u8981\u6c42&#xff1a;\u5fc5\u987b\u4f7f\u7528HTTPS\u534f\u8bae<\/p>\n<\/li>\n<li>\n<p>\u5e76\u53d1\u9650\u5236&#xff1a;\u6700\u591a\u540c\u65f6\u53d1\u8d7710\u4e2a\u7f51\u7edc\u8bf7\u6c42<\/p>\n<\/li>\n<h4>6.2 H5\u5e73\u53f0<\/h4>\n<li>\n<p>\u8de8\u57df\u95ee\u9898&#xff1a;\u9700\u8981\u540e\u7aef\u914d\u7f6eCORS\u6216\u4f7f\u7528\u4ee3\u7406<\/p>\n<\/li>\n<li>\n<p>Cookie\u5904\u7406&#xff1a;\u4e0e\u6d4f\u89c8\u5668\u884c\u4e3a\u4e00\u81f4&#xff0c;\u4f1a\u81ea\u52a8\u643a\u5e26cookie<\/p>\n<\/li>\n<h4>6.3 App\u5e73\u53f0<\/h4>\n<li>\n<p>SSL\u9a8c\u8bc1&#xff1a;\u53ef\u4ee5\u914d\u7f6e\u4e0d\u9a8c\u8bc1SSL\u8bc1\u4e66&#xff08;\u4ec5\u5f00\u53d1\u73af\u5883\u4f7f\u7528&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u672c\u5730\u7f13\u5b58&#xff1a;\u53ef\u4ee5\u4f7f\u7528\u672c\u5730\u7f13\u5b58\u7b56\u7565\u63d0\u5347\u6027\u80fd<\/p>\n<\/li>\n<li>\n<p>\u7f51\u7edc\u72b6\u6001\u68c0\u6d4b&#xff1a;\u53ef\u4ee5\u901a\u8fc7uni.getNetworkType\u83b7\u53d6\u7f51\u7edc\u7c7b\u578b<\/p>\n<\/li>\n<h3>\u4e03\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u6700\u4f73\u5b9e\u8df5<\/h3>\n<li>\n<p>\u5408\u7406\u8bbe\u7f6e\u7f13\u5b58&#xff1a;\u5bf9\u4e0d\u5e38\u53d8\u7684\u6570\u636e\u4f7f\u7528\u7f13\u5b58\u51cf\u5c11\u8bf7\u6c42<\/p>\n<\/li>\n<li>\n<p>\u5408\u5e76\u8bf7\u6c42&#xff1a;\u591a\u4e2a\u76f8\u5173\u8bf7\u6c42\u53ef\u4ee5\u5408\u5e76\u4e3a\u4e00\u4e2a<\/p>\n<\/li>\n<li>\n<p>\u53d6\u6d88\u65e0\u7528\u8bf7\u6c42&#xff1a;\u9875\u9762\u5378\u8f7d\u65f6\u53d6\u6d88\u672a\u5b8c\u6210\u7684\u8bf7\u6c42<\/p>\n<\/li>\n<li>\n<p>\u8282\u6d41\u4e0e\u9632\u6296&#xff1a;\u907f\u514d\u9891\u7e41\u89e6\u53d1\u76f8\u540c\u8bf7\u6c42<\/p>\n<\/li>\n<li>\n<p>\u9519\u8bef\u91cd\u8bd5\u673a\u5236&#xff1a;\u5bf9\u4e34\u65f6\u6027\u9519\u8bef\u5b9e\u73b0\u81ea\u52a8\u91cd\u8bd5<\/p>\n<\/li>\n<p>\/\/ \u8bf7\u6c42\u53d6\u6d88\u793a\u4f8b<br \/>\nlet requestTask &#061; uni.request({<br \/>\n  url: &#039;https:\/\/api.example.com\/data&#039;,<br \/>\n  success() {}<br \/>\n});<\/p>\n<p>\/\/ \u5728\u9875\u9762\u5378\u8f7d\u65f6\u53d6\u6d88\u8bf7\u6c42<br \/>\nonUnload() {<br \/>\n  requestTask.abort();<br \/>\n}<\/p>\n<p>\/\/ \u9519\u8bef\u91cd\u8bd5\u793a\u4f8b<br \/>\nfunction requestWithRetry(options, retry &#061; 3) {<br \/>\n  return new Promise((resolve, reject) &#061;&gt; {<br \/>\n    const wrappedRequest &#061; (attempt) &#061;&gt; {<br \/>\n      request(options)<br \/>\n        .then(resolve)<br \/>\n        .catch(err &#061;&gt; {<br \/>\n          if (attempt &lt; retry) {<br \/>\n            setTimeout(() &#061;&gt; wrappedRequest(attempt &#043; 1), 1000);<br \/>\n          } else {<br \/>\n            reject(err);<br \/>\n          }<br \/>\n        });<br \/>\n    };<br \/>\n    wrappedRequest(0);<br \/>\n  });<br \/>\n} <\/p>\n<h3>\u603b\u7ed3<\/h3>\n<p>Uniapp\u7684uni.request\u63d0\u4f9b\u4e86\u5f3a\u5927\u800c\u7075\u6d3b\u7684\u7f51\u7edc\u8bf7\u6c42\u80fd\u529b&#xff0c;\u901a\u8fc7\u5408\u7406\u7684\u5c01\u88c5\u548c\u6269\u5c55&#xff0c;\u53ef\u4ee5\u6ee1\u8db3\u5404\u79cd\u590d\u6742\u7684\u4e1a\u52a1\u573a\u666f\u9700\u6c42\u3002\u672c\u6587\u4ece\u57fa\u7840\u4f7f\u7528\u5230\u9ad8\u7ea7\u5c01\u88c5&#xff0c;\u5168\u9762\u4ecb\u7ecd\u4e86Uniapp\u7f51\u7edc\u8bf7\u6c42\u7684\u5404\u4e2a\u65b9\u9762&#xff0c;\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u66f4\u52a0\u5065\u58ee\u3001\u9ad8\u6548\u7684\u7f51\u7edc\u8bf7\u6c42\u4f53\u7cfb\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u9879\u76ee\u4e2d&#xff0c;\u5efa\u8bae\u6839\u636e\u56e2\u961f\u89c4\u8303\u548c\u9879\u76ee\u9700\u6c42&#xff0c;\u5f00\u53d1\u9002\u5408\u81ea\u5df1\u9879\u76ee\u7684\u8bf7\u6c42\u5de5\u5177\u5e93&#xff0c;\u7edf\u4e00\u5904\u7406\u8ba4\u8bc1\u3001\u9519\u8bef\u3001\u65e5\u5fd7\u7b49\u516c\u5171\u903b\u8f91&#xff0c;\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002<\/p>\n<p>\u8bb0\u4f4f&#xff0c;\u826f\u597d\u7684\u7f51\u7edc\u8bf7\u6c42\u5904\u7406\u4e0d\u4ec5\u80fd\u63d0\u5347\u5e94\u7528\u6027\u80fd&#xff0c;\u8fd8\u80fd\u663e\u8457\u6539\u5584\u7528\u6237\u4f53\u9a8c&#xff0c;\u662f\u9ad8\u8d28\u91cf\u5e94\u7528\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002<\/p>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb968\u6b21\uff0c\u70b9\u8d5e32\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u5728\u79fb\u52a8\u5e94\u7528\u548c\u8de8\u5e73\u53f0\u5f00\u53d1\u4e2d\uff0c\u7f51\u7edc\u8bf7\u6c42\u662f\u6700\u57fa\u7840\u4e5f\u662f\u6700\u91cd\u8981\u7684\u529f\u80fd\u4e4b\u4e00\u3002Uniapp\u4f5c\u4e3a\u4e00\u6b3e\u6d41\u884c\u7684\u8de8\u5e73\u53f0\u5f00\u53d1\u6846\u67b6\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u800c\u7075\u6d3b\u7684\u7f51\u7edc\u8bf7\u6c42API\u2014\u2014uni.request\u3002\u672c\u6587\u5c06\u5168\u9762\u4ecb\u7ecdUniapp\u7f51\u7edc\u8bf7\u6c42\u7684\u5404\u4e2a\u65b9\u9762\uff0c\u5305\u62ec\u57fa\u7840\u4f7f\u7528\u3001\u53c2\u6570\u8be6\u89e3\u3001\u9519\u8bef\u5904\u7406\u3001\u6027\u80fd\u4f18\u5316\u4ee5\u53ca\u9ad8\u7ea7\u5c01\u88c5\u6280\u5de7\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u5065\u58ee\u7684\u7f51\u7edc\u8bf7\u6c42\u4f53\u7cfb\u3002<\/p>\n","protected":false},"author":2,"featured_media":44278,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[387,588],"topic":[],"class_list":["post-44279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-uni-app","tag-uniapp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Uniapp\u7f51\u7edc\u8bf7\u6c42\u5168\u9762\u6307\u5357\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/44279.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Uniapp\u7f51\u7edc\u8bf7\u6c42\u5168\u9762\u6307\u5357\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb968\u6b21\uff0c\u70b9\u8d5e32\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u5728\u79fb\u52a8\u5e94\u7528\u548c\u8de8\u5e73\u53f0\u5f00\u53d1\u4e2d\uff0c\u7f51\u7edc\u8bf7\u6c42\u662f\u6700\u57fa\u7840\u4e5f\u662f\u6700\u91cd\u8981\u7684\u529f\u80fd\u4e4b\u4e00\u3002Uniapp\u4f5c\u4e3a\u4e00\u6b3e\u6d41\u884c\u7684\u8de8\u5e73\u53f0\u5f00\u53d1\u6846\u67b6\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u800c\u7075\u6d3b\u7684\u7f51\u7edc\u8bf7\u6c42API\u2014\u2014uni.request\u3002\u672c\u6587\u5c06\u5168\u9762\u4ecb\u7ecdUniapp\u7f51\u7edc\u8bf7\u6c42\u7684\u5404\u4e2a\u65b9\u9762\uff0c\u5305\u62ec\u57fa\u7840\u4f7f\u7528\u3001\u53c2\u6570\u8be6\u89e3\u3001\u9519\u8bef\u5904\u7406\u3001\u6027\u80fd\u4f18\u5316\u4ee5\u53ca\u9ad8\u7ea7\u5c01\u88c5\u6280\u5de7\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u5065\u58ee\u7684\u7f51\u7edc\u8bf7\u6c42\u4f53\u7cfb\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/44279.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-18T01:33:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250618013338-68521772ec78c.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/44279.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/44279.html\",\"name\":\"Uniapp\u7f51\u7edc\u8bf7\u6c42\u5168\u9762\u6307\u5357\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-18T01:33:42+00:00\",\"dateModified\":\"2025-06-18T01:33:42+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/44279.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/44279.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/44279.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Uniapp\u7f51\u7edc\u8bf7\u6c42\u5168\u9762\u6307\u5357\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5c01\u88c5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Uniapp\u7f51\u7edc\u8bf7\u6c42\u5168\u9762\u6307\u5357\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/44279.html","og_locale":"zh_CN","og_type":"article","og_title":"Uniapp\u7f51\u7edc\u8bf7\u6c42\u5168\u9762\u6307\u5357\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb968\u6b21\uff0c\u70b9\u8d5e32\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u5728\u79fb\u52a8\u5e94\u7528\u548c\u8de8\u5e73\u53f0\u5f00\u53d1\u4e2d\uff0c\u7f51\u7edc\u8bf7\u6c42\u662f\u6700\u57fa\u7840\u4e5f\u662f\u6700\u91cd\u8981\u7684\u529f\u80fd\u4e4b\u4e00\u3002Uniapp\u4f5c\u4e3a\u4e00\u6b3e\u6d41\u884c\u7684\u8de8\u5e73\u53f0\u5f00\u53d1\u6846\u67b6\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u800c\u7075\u6d3b\u7684\u7f51\u7edc\u8bf7\u6c42API\u2014\u2014uni.request\u3002\u672c\u6587\u5c06\u5168\u9762\u4ecb\u7ecdUniapp\u7f51\u7edc\u8bf7\u6c42\u7684\u5404\u4e2a\u65b9\u9762\uff0c\u5305\u62ec\u57fa\u7840\u4f7f\u7528\u3001\u53c2\u6570\u8be6\u89e3\u3001\u9519\u8bef\u5904\u7406\u3001\u6027\u80fd\u4f18\u5316\u4ee5\u53ca\u9ad8\u7ea7\u5c01\u88c5\u6280\u5de7\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u5065\u58ee\u7684\u7f51\u7edc\u8bf7\u6c42\u4f53\u7cfb\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/44279.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-18T01:33:42+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250618013338-68521772ec78c.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/44279.html","url":"https:\/\/www.wsisp.com\/helps\/44279.html","name":"Uniapp\u7f51\u7edc\u8bf7\u6c42\u5168\u9762\u6307\u5357\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5c01\u88c5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-18T01:33:42+00:00","dateModified":"2025-06-18T01:33:42+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/44279.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/44279.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/44279.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Uniapp\u7f51\u7edc\u8bf7\u6c42\u5168\u9762\u6307\u5357\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5c01\u88c5"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/44279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=44279"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/44279\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/44278"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=44279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=44279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=44279"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=44279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}