{"id":186807,"date":"2022-09-01T18:18:45","date_gmt":"2022-09-01T10:18:45","guid":{"rendered":"http:\/\/www.idc.net\/help\/186807\/"},"modified":"2022-09-01T18:18:45","modified_gmt":"2022-09-01T10:18:45","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%9aapp","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/186807\/","title":{"rendered":"\u540e\u6d6a\u4e91\u767e\u5ea6\u5c0f\u7a0b\u5e8f\u6559\u7a0b\uff1aApp"},"content":{"rendered":"<ul>\n<li>App\n<ul>\n<li>onLogin(Object object)<\/li>\n<li>onLaunch(Object object)<\/li>\n<li>onShow(Object object)<\/li>\n<li>onHide()<\/li>\n<li>onError(Object object)<\/li>\n<li>onPageNotFound(Object object)\n<ul><\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h1><span><\/span>App<\/h1>\n<p><strong>\u89e3\u91ca<\/strong>\uff1a App \u51fd\u6570\u7528\u6765\u6ce8\u518c\u4e00\u4e2a\u667a\u80fd\u5c0f\u7a0b\u5e8f\u3002\u63a5\u53d7\u4e00\u4e2a Object \u4f5c\u4e3a\u53c2\u6570\uff0c\u7528\u4ee5\u6307\u5b9a\u667a\u80fd\u5c0f\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u51fd\u6570\u7b49\u3002<\/p>\n<p><strong>\u6ce8\uff1aApp \u51fd\u6570\u5fc5\u987b\u5728 app.js \u4e2d\u88ab\u8c03\u7528\u4e00\u6b21\u3002\u8be5\u51fd\u6570\u5728\u6574\u4e2a\u5c0f\u7a0b\u5e8f\u4e2d\u4e0d\u80fd\u88ab\u8c03\u7528\u591a\u6b21\uff0c\u5426\u5219\u4f1a\u51fa\u73b0\u65e0\u6cd5\u9884\u671f\u7684\u540e\u679c\u3002<\/strong><\/p>\n<p><strong>Web \u6001\u8bf4\u660e<\/strong>\uff1a<\/p>\n<p>\u7531\u4e8e Web \u6001\u6846\u67b6\u6682\u4e0d\u652f\u6301\u5f53\u524d\u662f\u5426\u8fdb\u5165\u524d\u3001\u540e\u53f0\u7684\u72b6\u6001\u68c0\u6d4b\uff0c\u56e0\u6b64\u5728\u4e0b\u5217\u573a\u666f\u4e2d\uff0cApp.onShow\u3001App.onHide \u751f\u547d\u5468\u671f\u65e0\u6cd5\u89e6\u53d1<\/p>\n<ul>\n<li>\u5f53 Web \u6001\u5c0f\u7a0b\u5e8f\u4ece\u540e\u53f0\u5207\u6362\u81f3\u524d\u53f0\u65f6\uff0c\u5982\u4ece\u4efb\u52a1\u7ba1\u7406\u5668\u8fdb\u5165\u3001\u6216\u5173\u95ed\u663e\u793a\u5728\u4e0a\u5c42\u7684\u8bed\u97f3\u52a9\u624b\u7b49\uff0cApp.onShow \u751f\u547d\u5468\u671f\u65e0\u6cd5\u89e6\u53d1<\/li>\n<li>\u7531\u4e8e Web \u6001\u6846\u67b6\u6682\u4e0d\u652f\u6301\u5f53\u524d\u662f\u5426\u8fdb\u5165\u524d\u3001\u540e\u53f0\u7684\u72b6\u6001\u68c0\u6d4b\uff0c\u56e0\u6b64 Web \u6001\u5c0f\u7a0b\u5e8f\u6682\u4e0d\u652f\u6301 App.onHide \u751f\u547d\u5468\u671f<\/li>\n<\/ul>\n<p><strong>\u53c2\u6570<\/strong><\/p>\n<p><strong>Object object<\/strong>\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u89e6\u53d1\u65f6\u673a<\/th>\n<th>Web \u6001\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>onLogin<\/td>\n<td>Function<\/td>\n<td><\/td>\n<td>\u751f\u547d\u5468\u671f\u51fd\u6570 - \u76d1\u542c Web \u6001\u5c0f\u7a0b\u5e8f\u767b\u5f55\u6210\u529f( Web \u6001\u5c0f\u7a0b\u5e8f\u72ec\u6709)<\/td>\n<td>\u5f53\u5c0f\u7a0b\u5e8f\u521d\u6b21\u767b\u5f55\u6210\u529f\u540e\uff0c\u4f1a\u89e6\u53d1 onLogin \uff08\u5168\u5c40\u53ea\u89e6\u53d1\u4e00\u6b21\uff09<\/td>\n<td>\u4ec5\u5728 Web \u6001\u5c0f\u7a0b\u5e8f\u4e2d\u6709\u6548\uff0c\u767e\u5ea6 App \u7aef\u5185\u5c0f\u7a0b\u5e8f\u6b64\u751f\u547d\u5468\u671f\u4e0d\u4f1a\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td>onLaunch<\/td>\n<td>Function<\/td>\n<td><\/td>\n<td>\u751f\u547d\u5468\u671f\u51fd\u6570 - \u76d1\u542c\u5c0f\u7a0b\u5e8f\u7684\u521d\u59cb\u5316<\/td>\n<td>\u5f53\u5c0f\u7a0b\u5e8f\u521d\u59cb\u5316\u5b8c\u6210\u65f6\uff0c\u4f1a\u89e6\u53d1 onLaunch \uff08\u5168\u5c40\u53ea\u89e6\u53d1\u4e00\u6b21\uff09\u3002<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>onShow<\/td>\n<td>Function<\/td>\n<td><\/td>\n<td>\u751f\u547d\u5468\u671f\u51fd\u6570 - \u76d1\u542c\u5c0f\u7a0b\u5e8f\u7684\u663e\u793a<\/td>\n<td>\u5f53\u5c0f\u7a0b\u5e8f\u521d\u59cb\u5316\uff0c\u6216\u4ece\u540e\u53f0\u8fdb\u5165\u524d\u53f0\u663e\u793a\uff0c\u4f1a\u89e6\u53d1 onShow<\/td>\n<td>\u4ec5\u5728\u5c0f\u7a0b\u5e8f\u521d\u59cb\u5316\u65f6\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td>onHide<\/td>\n<td>Function<\/td>\n<td><\/td>\n<td>\u751f\u547d\u5468\u671f\u51fd\u6570 - \u76d1\u542c\u5c0f\u7a0b\u5e8f\u7684\u9690\u85cf<\/td>\n<td>\u5f53\u5c0f\u7a0b\u5e8f\u4ece\u524d\u53f0\u8fdb\u5165\u540e\u53f0\uff0c\u4f1a\u89e6\u53d1 onHide<\/td>\n<td>\u6682\u4e0d\u652f\u6301<\/td>\n<\/tr>\n<tr>\n<td>onError<\/td>\n<td>Function<\/td>\n<td><\/td>\n<td>\u9519\u8bef\u76d1\u542c\u51fd\u6570<\/td>\n<td>\u5c0f\u7a0b\u5e8f\u53d1\u751f\u811a\u672c\u9519\u8bef\uff0c\u6216\u8005 API \u8c03\u7528\u5931\u8d25\u65f6\u89e6\u53d1\uff0c\u4f1a\u5e26\u4e0a\u9519\u8bef\u4fe1\u606f<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>onPageNotFound<\/td>\n<td>Function<\/td>\n<td><\/td>\n<td>\u9875\u9762\u4e0d\u5b58\u5728\u76d1\u542c\u51fd\u6570<\/td>\n<td>\u5c0f\u7a0b\u5e8f\u8981\u6253\u5f00\u7684\u9875\u9762\u4e0d\u5b58\u5728\u65f6\u89e6\u53d1\uff0c\u4f1a\u5e26\u4e0a\u9875\u9762\u4fe1\u606f\u56de\u8c03\u8be5\u51fd\u6570\u3002<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u5176\u4ed6<\/td>\n<td>Any<\/td>\n<td><\/td>\n<td>\u5f00\u53d1\u8005\u53ef\u4ee5\u6dfb\u52a0\u4efb\u610f\u7684\u51fd\u6570\u6216\u8005\u6570\u636e\u5230 Object \u53c2\u6570\u4e2d\uff0c\u7528 this \u53ef\u4ee5\u8bbf\u95ee<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u540d\u8bcd\u89e3\u91ca<\/strong>:<br \/>\u524d\u53f0\u3001\u540e\u53f0\uff1a\u5f53\u7528\u6237\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u5173\u95ed\uff0c\u6216\u8005\u6309\u4e86\u8bbe\u5907\u7684 Home \u952e\u79bb\u5f00\u667a\u80fd\u5c0f\u7a0b\u5e8f\uff0c\u667a\u80fd\u5c0f\u7a0b\u5e8f\u6ca1\u6709\u76f4\u63a5\u9500\u6bc1\uff0c\u800c\u662f\u8fdb\u5165\u5230\u4e86\u540e\u53f0\uff1b\u5f53\u518d\u6b21\u8fdb\u5165\u667a\u80fd\u5c0f\u7a0b\u5e8f\uff0c\u53c8\u4f1a\u4ece\u540e\u53f0\u8fdb\u5165\u524d\u53f0\u3002<\/p>\n<p><strong>\u6ce8\u610f<\/strong>:<br \/>\u53ea\u6709\u5728\u4ee5\u4e0b\u60c5\u51b5\u5c0f\u7a0b\u5e8f\u624d\u53ef\u80fd\u4f1a\u88ab\u52a8\u9500\u6bc1\uff0c\u53c2\u8003\u8fd0\u884c\u673a\u5236:<\/p>\n<ul>\n<li>\u8fdb\u5165\u540e\u53f0\u8d85\u8fc7 5 \u5206\u949f\uff1b<\/li>\n<li>\u7cfb\u7edf\u8d44\u6e90\u5360\u7528\u8fc7\u9ad8\uff1b<\/li>\n<li>\u6253\u5f00\u5c0f\u7a0b\u5e8f\u6570\u91cf\u8d85\u8fc7\u7cfb\u7edf\u652f\u6301\u4e0a\u9650(\u7cfb\u7edf\u6309\u7167\u5c0f\u7a0b\u5e8f\u88ab\u6253\u5f00\u7684\u5148\u540e\u987a\u5e8f\u8fdb\u884c\u9500\u6bc1)\u3002<\/li>\n<\/ul>\n<p><strong>\u4ee3\u7801\u793a\u4f8b<\/strong><\/p>\n<ul>\n<li>JS<\/li>\n<\/ul>\n<pre>\n \n \n <ol>\n  \n  \n  <li><code><span>\/\/ app.js<\/span><\/code><\/li>\n  \n  \n  <li><code><span>App<\/span><span>({<\/span><\/code><\/li>\n  \n  \n  <li><code><span> onLogin<\/span><span>(<\/span><span>options<\/span><span>)<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>\/\/ \u4f7f\u7528 options.code \u6362\u53d6 session_key<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>\/\/ \u4ec5\u5728 Web \u6001\u5c0f\u7a0b\u5e8f\u521d\u6b21\u767b\u5f55\u6210\u529f\u540e\u4f1a\u88ab\u89e6\u53d1<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>},<\/span><\/code><\/li>\n  \n  \n  <li><code><span> onLaunch<\/span><span>(<\/span><span>options<\/span><span>)<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>\/\/ Do something initial when launch.<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>},<\/span><\/code><\/li>\n  \n  \n  <li><code><span> onShow<\/span><span>(<\/span><span>options<\/span><span>)<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>\/\/ Do something when show.<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>},<\/span><\/code><\/li>\n  \n  \n  <li><code><span> onHide<\/span><span>()<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>\/\/ Do something when hide.<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>},<\/span><\/code><\/li>\n  \n  \n  <li><code><span> onError<\/span><span>(<\/span><span>errMsg<\/span><span>)<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>\/\/ \u53d1\u751f\u9519\u8bef\u65f6\uff0c\u56de\u8c03\u6b64\u65b9\u6cd5\u5e76\u4f20\u9012\u9519\u8bef\u4fe1\u606f<\/span><\/code><\/li>\n  \n  \n  <li><code><span> console<\/span><span>.<\/span><span>log<\/span><span>(<\/span><span>errMsg<\/span><span>);<\/span><span> <\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>},<\/span><\/code><\/li>\n  \n  \n  <li><code><span> globalData<\/span><span>:<\/span><span> <\/span><span>'This is global data'<\/span><\/code><\/li>\n  \n  \n  <li><code><span>});<\/span><\/code><\/li>\n \n \n <\/ol><\/pre>\n<h2><span><\/span>onLogin(Object object)<\/h2>\n<ul>\n<li>\u4f7f\u7528 onLogin \u751f\u547d\u5468\u671f\u7684\u610f\u4e49\uff1aWeb \u6001\u5c0f\u7a0b\u5e8f\u521d\u6b21\u767b\u5f55\u6210\u529f\u540e\u5f00\u53d1\u8005\u80fd\u83b7\u53d6\u767b\u5f55\u6210\u529f\u7684 code\u3002<\/li>\n<li><strong>\u6dfb\u52a0 onLogin \u751f\u547d\u5468\u671f\u7684\u539f\u56e0<\/strong>\uff1a\u4e0e\u767e\u5ea6 App \u7aef\u5185\u5c0f\u7a0b\u5e8f\u767b\u5f55\u4e0d\u540c\uff08\u5728\u5c0f\u7a0b\u5e8f\u5185\u90e8\u767b\u5f55\uff09\uff0cWeb \u6001\u7684\u767b\u5f55\u9700\u8981\u8df3\u8f6c\u767e\u5ea6\u767b\u5f55\u9875\u9762\u8fdb\u884c\u767b\u5f55\uff0c\u767b\u5f55\u6210\u529f\u540e\u81ea\u52a8\u8df3\u8f6c\u539f\u9875\u9762\u3002\u8be5\u8df3\u8f6c\u8fc7\u7a0b\u4f1a\u5bfc\u81f4 Web \u6001\u5c0f\u7a0b\u5e8f\u7684\u539f\u6267\u884c\u4e0a\u4e0b\u6587\u72b6\u6001\u4e22\u5931\uff0c\u4ece\u800c\u65e0\u6cd5\u901a\u8fc7 swan.login \u7684\u6210\u529f\u56de\u8c03\u83b7\u53d6\u767b\u5f55\u6210\u529f\u7684 code\u3002\u56e0\u6b64\u5fc5\u987b\u901a\u8fc7 onLogin \u751f\u547d\u5468\u671f\u83b7\u53d6\u8be5 code\u3002<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u6bb5<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>code<\/td>\n<td>String<\/td>\n<td>\u767b\u5f55\u6210\u529f\u540e\u7684 code\uff0c\u7528\u4e8e\u6362\u53d6 session_key<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span><\/span>onLaunch(Object object)<\/h2>\n<p>\u5c0f\u7a0b\u5e8f\u521d\u59cb\u5316\u5b8c\u6210\u65f6\u89e6\u53d1\uff0c\u5168\u5c40\u53ea\u89e6\u53d1\u4e00\u6b21\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u6bb5<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>scene<\/td>\n<td>String<\/td>\n<td>\u6253\u5f00\u667a\u80fd\u5c0f\u7a0b\u5e8f\u7684\u573a\u666f\u503c\uff0cscene \u503c\u7edf\u4e00\u7531\u767e\u5ea6\u5c0f\u7a0b\u5e8f\u573a\u666f\u503c\u7ba1\u7406\u4e2d\u5fc3\u5728 B \u7aef\u5e73\u53f0\u7edf\u4e00\u914d\u7f6e\u540e\u4e0b\u53d1\u5230\u5bbf\u4e3b\uff08\u4f8b\u5982\u767e\u5ea6 App\uff09\uff0c\u8c03\u8d77\u534f\u8bae\u4e2d\u4f1a\u643a\u5e26\u76f8\u5e94\u5165\u53e3\u7684 scene \u503c<\/td>\n<\/tr>\n<tr>\n<td>path<\/td>\n<td>String<\/td>\n<td>\u6253\u5f00\u5c0f\u7a0b\u5e8f\u7684\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td>query<\/td>\n<td>Object<\/td>\n<td>\u6253\u5f00\u5f53\u524d\u9875\u9762\u8def\u5f84\u4e2d\u7684\u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td>shareTicket<\/td>\n<td>String<\/td>\n<td>\u6807\u8bb0\u8f6c\u53d1\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>referrerInfo<\/td>\n<td>Object<\/td>\n<td>\u4ece\u53e6\u4e00\u4e2a\u5c0f\u7a0b\u5e8f\u6253\u5f00\u8be5\u5c0f\u7a0b\u5e8f\u65f6\uff0c\u8fd4\u56de\u6b64\u5b57\u6bb5<\/td>\n<\/tr>\n<tr>\n<td>referrerInfo.appId<\/td>\n<td>String<\/td>\n<td>\u6765\u6e90\u5c0f\u7a0b\u5e8f\u7684 appKey<\/td>\n<\/tr>\n<tr>\n<td>referrerInfo.extraData<\/td>\n<td>Object<\/td>\n<td>\u6765\u6e90\u5c0f\u7a0b\u5e8f\u4f20\u8fc7\u6765\u7684\u6570\u636e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u540d\u8bcd\u89e3\u91ca<\/strong>:<\/p>\n<ul>\n<li>\u573a\u666f\u503c\uff1a \u667a\u80fd\u5c0f\u7a0b\u5e8f\u88ab\u6253\u5f00\u65f6\uff0c\u5176\u6765\u6e90\u6e20\u9053\u7684\u6807\u8bc6\uff08\u4f8b\u5982\uff1a \u4ece\u767e\u5ea6\u641c\u7d22\u7ed3\u679c\u6253\u5f00\u3001\u4ece\u767e\u5ea6\u4fe1\u606f\u6d41\u6253\u5f00\uff09\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5229\u7528\u8be5\u5b57\u6bb5\u7edf\u8ba1\u5c0f\u7a0b\u5e8f\u5728\u4ec0\u4e48\u573a\u666f\u4e0b\u88ab\u6253\u5f00\uff0c\u66f4\u591a\u573a\u666f\u503c\uff1b<\/li>\n<li>\u8c03\u8d77\u534f\u8bae\uff1a \u5bbf\u4e3b\uff08\u4f8b\u5982\u767e\u5ea6 App\uff09\u7528\u4e8e\u8bc6\u522b\u4e00\u4e2a\u5c0f\u7a0b\u5e8f\u88ab\u6253\u5f00\u65f6\u7684\u521d\u59cb\u5316\u4fe1\u606f\uff08\u4f8b\u5982\uff1a\u5c0f\u7a0b\u5e8f\u7684 appKey\u3001path\u3001query \u7b49\uff09\uff0c\u7531\u8be5\u7c7b\u4fe1\u606f\u6784\u6210\u7684\u4e00\u4e2a\u534f\u8bae\u3002<\/li>\n<\/ul>\n<h2><span><\/span>onShow(Object object)<\/h2>\n<p>\u5c0f\u7a0b\u5e8f\u542f\u52a8\uff0c\u6216\u4ece\u540e\u53f0\u8fdb\u5165\u524d\u53f0\u663e\u793a\u65f6\u89e6\u53d1\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528 swan.onAppShow \u7ed1\u5b9a\u76d1\u542c\u3002<\/p>\n<p><strong>\u53c2\u6570<\/strong>\uff1a\u4e0e swan.onAppShow \u4e00\u81f4<\/p>\n<h2><span><\/span>onHide()<\/h2>\n<p>\u5c0f\u7a0b\u5e8f\u4ece\u524d\u53f0\u8fdb\u5165\u540e\u53f0\u65f6\u89e6\u53d1\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528 swan.onAppHide \u7ed1\u5b9a\u76d1\u542c\u3002<\/p>\n<h2><span><\/span>onError(Object object)<\/h2>\n<p>\u5c0f\u7a0b\u5e8f\u53d1\u751f\u811a\u672c\u9519\u8bef\u6216 API \u8c03\u7528\u62a5\u9519\u65f6\u89e6\u53d1\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528 swan.onError \u7ed1\u5b9a\u76d1\u542c\u3002<\/p>\n<p><strong>\u53c2\u6570<\/strong>\uff1a\u4e0e swan.onError \u4e00\u81f4<\/p>\n<h2><span><\/span>onPageNotFound(Object object)<\/h2>\n<p>\u5c0f\u7a0b\u5e8f\u8981\u6253\u5f00\u7684\u9875\u9762\u4e0d\u5b58\u5728\u65f6\u89e6\u53d1\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528 swan.onPageNotFound \u7ed1\u5b9a\u76d1\u542c\u3002\u6ce8\u610f\u4e8b\u9879\u8bf7\u53c2\u8003 swan.onPageNotFound\u3002<\/p>\n<p><strong>\u53c2\u6570<\/strong>\uff1a\u4e0e swan.onPageNotFound \u4e00\u81f4<\/p>\n<p><strong>\u4ee3\u7801\u793a\u4f8b<\/strong><\/p>\n<ul>\n<li>JS<\/li>\n<\/ul>\n<pre>\n \n \n <ol>\n  \n  \n  <li><code><span>\/\/ app.js<\/span><\/code><\/li>\n  \n  \n  <li><code><span>App<\/span><span>({<\/span><\/code><\/li>\n  \n  \n  <li><code><span> onPageNotFound<\/span><span>(<\/span><span>res<\/span><span>)<\/span><span> <\/span><span>{<\/span><\/code><\/li>\n  \n  \n  <li><code><span> <\/span><span>\/\/ \u5982\u679c\u662f tabbar \u9875\u9762\uff0c\u8bf7\u4f7f\u7528 swan.switchTab \u8fdb\u884c\u8df3\u8f6c<\/span><\/code><\/li>\n  \n  \n  <li><code><span> swan<\/span><span>.<\/span><span>redirectTo<\/span><span>({<\/span><\/code><\/li>\n  \n  \n  <li><code><span> url<\/span><span>:<\/span><span> <\/span><span>'path\/to\/otherPage'<\/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>App onLogin(Object object) onLaunch(Object object) onSh [&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-186807","post","type-post","status-publish","format-standard","hentry","category-mini-program"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/186807","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=186807"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/186807\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=186807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=186807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=186807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}