{"id":32761,"date":"2024-11-25T09:04:45","date_gmt":"2024-11-25T01:04:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/32761\/"},"modified":"2024-11-25T09:04:45","modified_gmt":"2024-11-25T01:04:45","slug":"%e5%b0%8f%e7%a8%8b%e5%ba%8f%e7%94%a8%e6%88%b7%e6%8e%88%e6%9d%83%e5%90%8e%e6%80%8e%e4%b9%88%e8%bf%94%e5%9b%9e%e9%a6%96%e9%a1%b5","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/32761\/","title":{"rendered":"\u5c0f\u7a0b\u5e8f\u7528\u6237\u6388\u6743\u540e\u600e\u4e48\u8fd4\u56de\u9996\u9875"},"content":{"rendered":"<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/040\/5e748fb1c3700755.jpg\" class=\"aligncenter\" title=\"\u5c0f\u7a0b\u5e8f\u7528\u6237\u6388\u6743\u540e\u600e\u4e48\u8fd4\u56de\u9996\u9875\u63d2\u56fe\" alt=\"\u5c0f\u7a0b\u5e8f\u7528\u6237\u6388\u6743\u540e\u600e\u4e48\u8fd4\u56de\u9996\u9875\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5c0f\u7a0b\u5e8f\u7528\u6237\u6388\u6743\u540e\u600e\u4e48\u8fd4\u56de\u9996\u9875<\/strong><\/p>\n<p>\u5b9e\u73b0\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5177\u4f53\u5982\u4e0b\uff1a<\/p>\n<p><strong>1\u3001\u4f7f\u7528 wx.navigateBack(Object object) <\/strong>\u5173\u95ed\u5f53\u524d\u9875\u9762\uff0c\u8fd4\u56de\u4e0a\u4e00\u9875\u9762\u6216\u591a\u7ea7\u9875\u9762\u3002\u53ef\u901a\u8fc7&nbsp;getCurrentPages&nbsp;\u83b7\u53d6\u5f53\u524d\u7684\u9875\u9762\u6808\uff0c\u51b3\u5b9a\u9700\u8981\u8fd4\u56de\u51e0\u5c42\u3002<\/p>\n<p>\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>\/\/ \u6b64\u5904\u662fA\u9875\u9762\nwx.navigateTo({\n  url: 'B?id=1'\n})\n\n\/\/ \u6b64\u5904\u662fB\u9875\u9762\nwx.navigateTo({\n  url: 'C?id=1'\n})\n\n\/\/ \u5728C\u9875\u9762\u5185 navigateBack\uff0c\u5c06\u8fd4\u56deA\u9875\u9762\nwx.navigateBack({\n  delta: 2\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2\u3001\u4f7f\u7528&nbsp;wx.navigateTo(Object object) <\/strong>\u8df3\u8f6c\u9875\u9762\uff0c\u4fdd\u7559\u5f53\u524d\u9875\u9762\uff0c\u8df3\u8f6c\u5230\u5e94\u7528\u5185\u7684\u67d0\u4e2a\u9875\u9762\u3002\u4f46\u662f\u4e0d\u80fd\u8df3\u5230 tabbar \u9875\u9762\u3002<\/p>\n<p>\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>wx.navigateTo({\n  url: 'test?id=1',\n  events: {\n    \/\/ \u4e3a\u6307\u5b9a\u4e8b\u4ef6\u6dfb\u52a0\u4e00\u4e2a\u76d1\u542c\u5668\uff0c\u83b7\u53d6\u88ab\u6253\u5f00\u9875\u9762\u4f20\u9001\u5230\u5f53\u524d\u9875\u9762\u7684\u6570\u636e\n    acceptDataFromOpenedPage: function(data) {\n      console.log(data)\n    },\n    someEvent: function(data) {\n      console.log(data)\n    }\n    ...\n  },\n  success: function(res) {\n    \/\/ \u901a\u8fc7eventChannel\u5411\u88ab\u6253\u5f00\u9875\u9762\u4f20\u9001\u6570\u636e\n    res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })\n  }\n})\n\n\/\/test.js\nPage({\n  onLoad: function(option){\n    console.log(option.query)\n    const eventChannel = this.getOpenerEventChannel()\n    eventChannel.emit('acceptDataFromOpenedPage', {data: 'test'});\n    eventChannel.emit('someEvent', {data: 'test'});\n    \/\/ \u76d1\u542cacceptDataFromOpenerPage\u4e8b\u4ef6\uff0c\u83b7\u53d6\u4e0a\u4e00\u9875\u9762\u901a\u8fc7eventChannel\u4f20\u9001\u5230\u5f53\u524d\u9875\u9762\u7684\u6570\u636e\n    eventChannel.on('acceptDataFromOpenerPage', function(data) {\n      console.log(data)\n    })\n  }\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3\u3001\u4f7f\u7528wx.redirectTo(Object object)<\/strong>\u5173\u95ed\u5f53\u524d\u9875\u9762\uff0c\u8df3\u8f6c\u5230\u5e94\u7528\u5185\u7684\u67d0\u4e2a\u9875\u9762\u3002\u4f46\u662f\u4e0d\u5141\u8bb8\u8df3\u8f6c\u5230 tabbar \u9875\u9762\u3002<\/p>\n<p>\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<pre>wx.redirectTo({\n  url: 'test?id=1'\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4\u3001\u4f7f\u7528wx.reLaunch(Object object)<\/strong>\u5173\u95ed\u6240\u6709\u9875\u9762\uff0c\u6253\u5f00\u5230\u5e94\u7528\u5185\u7684\u67d0\u4e2a\u9875\u9762<\/p>\n<p>\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<pre>wx.reLaunch({\n  url: 'test?id=1'\n})\n\/\/ test\nPage({\n  onLoad (option) {\n    console.log(option.query)\n  }\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u63a8\u8350\u5b66\u4e60\uff1a<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5c0f\u7a0b\u5e8f\u7528\u6237\u6388\u6743\u540e\u600e\u4e48\u8fd4\u56de\u9996\u9875\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c0f\u7a0b\u5e8f\u7528\u6237\u6388\u6743\u540e\u600e\u4e48\u8fd4\u56de\u9996\u9875 \u5b9e\u73b0\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5177\u4f53\u5982\u4e0b\uff1a 1\u3001\u4f7f\u7528 wx.navigateBack(Object object) \u5173\u95ed\u5f53\u524d\u9875\u9762\uff0c\u8fd4\u56de\u4e0a\u4e00\u9875\u9762\u6216\u591a\u7ea7\u9875\u9762\u3002\u53ef\u901a\u8fc7&nbsp;getCurrentPages&nbsp;\u83b7\u53d6\u5f53\u524d\u7684\u9875\u9762\u6808\uff0c\u51b3\u5b9a\u9700\u8981\u8fd4\u56de\u51e0\u5c42\u3002 \u793a\u4f8b\u4ee3\u7801\uff1a \/\/ \u6b64\u5904\u662fA\u9875\u9762 wx.navigateTo({ url: &#8216;B?id=1&#8217; }) \/\/ \u6b64\u5904\u662fB\u9875\u9762 wx.navigateTo({ url: &#8216;C?id=1&#8217; }) \/\/ \u5728C\u9875\u9762\u5185 navigateBack\uff0c\u5c06\u8fd4\u56deA\u9875\u9762 wx.navigateBack({ delta: 2 }) \u767b\u5f55\u540e\u590d\u5236 2\u3001\u4f7f\u7528&nbsp;wx.navigateTo(Object object) \u8df3\u8f6c\u9875\u9762\uff0c\u4fdd\u7559\u5f53\u524d\u9875\u9762\uff0c\u8df3\u8f6c\u5230\u5e94\u7528\u5185\u7684\u67d0\u4e2a\u9875\u9762\u3002\u4f46\u662f\u4e0d\u80fd\u8df3\u5230 tabbar \u9875\u9762\u3002 \u793a\u4f8b\u4ee3\u7801\uff1a wx.navigateTo({ url: &#8216;test?id=1&#8217;, events: { \/\/ \u4e3a\u6307\u5b9a\u4e8b\u4ef6\u6dfb\u52a0\u4e00\u4e2a\u76d1\u542c\u5668\uff0c\u83b7\u53d6\u88ab\u6253\u5f00\u9875\u9762\u4f20\u9001\u5230\u5f53\u524d\u9875\u9762\u7684\u6570\u636e acceptDataFromOpenedPage: function(data) { console.log(data) }, someEvent: function(data) { console.log(data) } &#8230; }, success: function(res) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-32761","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=32761"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32761\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=32761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=32761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=32761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}