{"id":186800,"date":"2023-09-05T03:00:16","date_gmt":"2023-09-04T19:00:16","guid":{"rendered":"http:\/\/www.idc.net\/help\/186800\/"},"modified":"2023-09-05T03:00:16","modified_gmt":"2023-09-04T19:00:16","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91%e7%99%be%e5%ba%a6%e5%b0%8f%e7%a8%8b%e5%ba%8f%e6%95%99%e7%a8%8b%ef%bc%9aswan-after","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/186800\/","title":{"rendered":"\u540e\u6d6a\u4e91\u767e\u5ea6\u5c0f\u7a0b\u5e8f\u6559\u7a0b\uff1aswan.after"},"content":{"rendered":"<ul>\n<li>swan.after\n<ul><\/ul>\n<\/li>\n<\/ul>\n<h1><span><\/span>swan.after<\/h1>\n<p><strong>\u89e3\u91ca<\/strong>\uff1aswan.after \u53ef\u4ee5\u62e6\u622a\u6240\u6709\u5f53\u524d\u8fd0\u884c\u5c0f\u7a0b\u5e8f\u5bf9\u4e8e API \u7684\u8c03\u7528\uff0c\u9ed8\u8ba4\u4f20\u5165<code>function<\/code>\u65f6\uff0c\u53ea\u5728 API \u51fd\u6570\u8c03\u7528\u7684\u8fd4\u56de\u9636\u6bb5\u62e6\u622a\u3002\u5982\u679c\u4f20\u5165 Object\uff0c\u5219\u53ef\u4ee5\u9009\u62e9\u62e6\u622a\u7684\u9636\u6bb5\uff08\u4f8b\u5982: \u8fd4\u56de\u9636\u6bb5\u3001\u56de\u8c03\u8c03\u7528\u9636\u6bb5\uff09\u3002<\/p>\n<p><strong>\u65b9\u6cd5\u53c2\u6570<\/strong>\uff1aObject<\/p>\n<p><strong>Object \u53c2\u6570\u8bf4\u660e<\/strong>\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027\u540d<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c \u5fc5\u586b<\/th>\n<th><\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>[key]<\/td>\n<td>String<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u8981\u62e6\u622a\u7684 API \u7684\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td>[value]<\/td>\n<td>Object \/ Function<\/td>\n<td><\/td>\n<td>\u5426<\/td>\n<td>\u62e6\u622a\u4e4b\u540e\u7684\u5904\u7406\u5668(\u5982\u679c\u4e3a function\uff0c\u5219\u9ed8\u8ba4\u5728 returning \u9636\u6bb5\u8c03\u7528)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u53ef\u62e6\u622a\u7684\u6240\u6709\u65b9\u6cd5<\/strong><\/p>\n<p>\u53c2\u89c1 API \u6587\u6863\uff0cAPI \u4e2d\u6240\u6709 swan \u8c03\u7528\u7684\u5747\u53ef\u4ee5\u62e6\u622a<\/p>\n<p><strong>\u4ee3\u7801\u793a\u4f8b<\/strong><\/p>\n<pre>\n \n \n <ol>\n  \n  \n  <li><code><span>swan<\/span><span>.<\/span><span>after<\/span><span>({<\/span><\/code><\/li>\n  \n  \n  <li><code><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>\/\/ \u9ed8\u8ba4\u5728returning\u9636\u6bb5\u8fdb\u884c\u62e6\u622a<\/span><\/code><\/li>\n  \n  \n  <li><code><span> request<\/span><span>:<\/span><span> <\/span><span>function<\/span><span> <\/span><span>(<\/span><span>context<\/span><span>)<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> console<\/span><span>.<\/span><span>log<\/span><span>(<\/span><span>'do something after request returning'<\/span><span>);<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>},<\/span><\/code><\/li>\n  \n  \n  <li><code><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>\/\/ \u53ef\u4ee5\u62e6\u622asuccess\u8fd4\u56de\uff0cfail\u8fd4\u56de\uff0c\u4e0ereturning<\/span><\/code><\/li>\n  \n  \n  <li><code><span> request<\/span><span>:<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><\/code><\/li>\n  \n  \n  <li><code><span> success<\/span><span>(<\/span><span>context<\/span><span>)<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> console<\/span><span>.<\/span><span>log<\/span><span>(<\/span><span>'do something after request success callback'<\/span><span>);<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>},<\/span><\/code><\/li>\n  \n  \n  <li><code><\/code><\/li>\n  \n  \n  <li><code><span> fail<\/span><span>(<\/span><span>context<\/span><span>)<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> console<\/span><span>.<\/span><span>log<\/span><span>(<\/span><span>'do something after request fail callback'<\/span><span>);<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>},<\/span><\/code><\/li>\n  \n  \n  <li><code><\/code><\/li>\n  \n  \n  <li><code><span> returning<\/span><span>(<\/span><span>context<\/span><span>)<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> console<\/span><span>.<\/span><span>log<\/span><span>(<\/span><span>'do something after request returning'<\/span><span>);<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>}<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>}<\/span><\/code><\/li>\n  \n  \n  <li><code><span>});<\/span><\/code><\/li>\n \n \n <\/ol><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>swan.after swan.after \u89e3\u91ca\uff1aswan.after \u53ef\u4ee5\u62e6\u622a\u6240\u6709\u5f53\u524d\u8fd0\u884c\u5c0f\u7a0b\u5e8f\u5bf9\u4e8e API [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182398],"tags":[],"class_list":["post-186800","post","type-post","status-publish","format-standard","hentry","category-mini-program"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/186800","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=186800"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/186800\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=186800"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=186800"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=186800"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}