{"id":34151,"date":"2024-11-25T15:54:54","date_gmt":"2024-11-25T07:54:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/34151\/"},"modified":"2024-11-25T15:54:54","modified_gmt":"2024-11-25T07:54:54","slug":"%e5%b0%8f%e7%a8%8b%e5%ba%8f%e4%b8%ad%e6%80%8e%e4%b9%88%e8%bf%9b%e8%a1%8c%e7%88%b6%e5%ad%90%e7%bb%84%e4%bb%b6%e4%bc%a0%e5%80%bc%e5%92%8c%e6%96%b9%e6%b3%95%e8%b0%83%e7%94%a8%ef%bc%9f%ef%bc%88%e6%96%b9","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/34151\/","title":{"rendered":"\u5c0f\u7a0b\u5e8f\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\uff08\u65b9\u6cd5\u6c47\u603b\uff09"},"content":{"rendered":"<p>\u5c0f\u7a0b\u5e8f\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\u4e0b\u9762\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u6c47\u603b\u5206\u4eab\u4e00\u4e9b\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u53ca\u65b9\u6cd5\u8c03\u7528\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/024\/61b16392a020a313.jpg\" class=\"aligncenter\" title=\"\u5c0f\u7a0b\u5e8f\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\uff08\u65b9\u6cd5\u6c47\u603b\uff09\u63d2\u56fe\" alt=\"\u5c0f\u7a0b\u5e8f\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\uff08\u65b9\u6cd5\u6c47\u603b\uff09\u63d2\u56fe\" \/><\/p>\n<h2>\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5c01\u88c5<\/h2>\n<p><strong>\u6ce8\u518c\u4e00\u4e2a tab \u7ec4\u4ef6<\/strong><\/p>\n<p>\u5728 components \u6587\u4ef6\u5939\u4e0b\uff0c\u521b\u5efa\u4e00\u4e2atabs\u6587\u4ef6\u5939\uff0c\u70b9\u51fbtabs\u53f3\u5efa\u5c31\u80fd\u770b\u5230\u4e00\u4e2a\u65b0\u5efacompoent\uff0c\u70b9\u5b8c\u4e00\u4e2a\u65b0\u7684\u7ec4\u4ef6\u5c31\u6ce8\u518c\u6210\u529f\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/image\/209\/600\/565\/1639015085261013.png\" class=\"aligncenter\" title=\"\u5c0f\u7a0b\u5e8f\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\uff08\u65b9\u6cd5\u6c47\u603b\uff09\u63d2\u56fe1\" alt=\"\u5c0f\u7a0b\u5e8f\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\uff08\u65b9\u6cd5\u6c47\u603b\uff09\u63d2\u56fe1\" \/><\/p>\n<p><strong>\u7ec4\u4ef6\u4f7f\u7528<\/strong><\/p>\n<p>\u5728\u9700\u8981\u4f7f\u7528\u8be5\u7ec4\u4ef6\u7684\u9875\u9762\u7684 json \u9875\u9762\u4e0a\u5bfc\u5165\u7ec4\u4ef6\uff0c\u5728 wxml \u4e0b\u50cf HTML \u6807\u7b7e\u4e00\u6837\u4f7f\u7528\u5c31\u597d\u4e86\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/image\/311\/278\/700\/1639015089521850.png\" class=\"aligncenter\" title=\"\u5c0f\u7a0b\u5e8f\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\uff08\u65b9\u6cd5\u6c47\u603b\uff09\u63d2\u56fe2\" alt=\"\u5c0f\u7a0b\u5e8f\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\uff08\u65b9\u6cd5\u6c47\u603b\uff09\u63d2\u56fe2\" \/><\/p>\n<pre>&lt;tabs&gt;&lt;\/tabs&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ec0\u4e48\u662f\u7236\u7ec4\u4ef6\uff0c\u4ec0\u4e48\u662f\u5b50\u7ec4\u4ef6\uff1f\u7236\u7ec4\u4ef6\u5c31\u662f\u5728\u9875\u9762\u4e2d\u9700\u8981\u5f15\u5165\u5176\u4ed6\u7684\u7ec4\u4ef6\u7684\u7ec4\u4ef6\uff0c\u800c\u5b50\u7ec4\u4ef6\u5c31\u662f\u5f15\u5165\u7684\u7ec4\u4ef6\u3002\u7236\u5411\u5b50\u4f20\u9012\u6570\u503c\uff0c\u662f\u901a\u8fc7\u5c5e\u6027\u7684\u65b9\u5f0f\u6765\u4f20\u503c\uff0c\u800c\u5b50\u5411\u7236\u4f20\u503c\u8fd8\u8981\u901a\u8fc7\u65b9\u6cd5\u7684\u65b9\u5f0f\u6765\u4f20\u503c\u3002<\/p>\n<p><strong><span style=\"font-size: 18px\">\u7236\u7ec4\u4ef6\u5411\u5b50\u7ec4\u4ef6\u4f20\u503c<\/span><\/strong><\/p>\n<p>\u7236\u7ec4\u4ef6\u901a\u8fc7\u5c5e\u6027\u4f20\u503c<\/p>\n<pre>&lt;childele&gt;&lt;\/childele&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5b50\u7ec4\u4ef6\u901a\u8fc7properties\u63a5\u6536\uff1a<\/p>\n<pre>properties:&nbsp;{\n\tchildParams:&nbsp;{&nbsp;type:&nbsp;String&nbsp;}\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong><span style=\"font-size: 18px\">\u5b50\u7ec4\u4ef6\u8c03\u7528\u7236\u7ec4\u4ef6\u65b9\u6cd5<\/span><\/strong><\/p>\n<p>\u8fd9\u4e2a\u65b9\u6cd5\u4e5f\u53ef\u4ee5\u7406\u89e3\u4e3a\u5b50\u7ec4\u4ef6\u5411\u7236\u7ec4\u4ef6\u4f20\u9012\u53c2\u6570\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u7236\u7ec4\u4ef6\u5b9a\u4e49\u65b9\u6cd5\uff0cchildFun\u662f\u5b50\u7ec4\u4ef6\u4e2d\u7684\u65b9\u6cd5\u540d\uff0cfun\u662f\u7236\u7ec4\u4ef6\u4e2d\u7684\u65b9\u6cd5\u540d\u3002\u6211\u4eec\u901a\u8fc7chidlFun\u6765\u8c03\u7528fun\u3002<\/p>\n<pre>&lt;childele&gt;&lt;\/childele&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7236\u7ec4\u4ef6\u65b9\u6cd5\uff1a<\/p>\n<pre>childFun(e){\n\tconsole.log('\u6211\u662f\u7236\u7ec4\u4ef6\u7684\u65b9\u6cd5',&nbsp;e)\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5f53\u70b9\u51fb\u5b50\u7ec4\u4ef6\u7684\u6309\u94ae\u6267\u884c clickFun \u65f6\u8c03\u7528\u7236\u7ec4\u4ef6\u7684\u65b9\u6cd5<\/p>\n<pre>clickFun(){\n\tthis.triggerEvent('childFun');\/\/\u5982\u679c\u9700\u8981\u4f20\u9012\u53c2\u6570\uff0c\u76f4\u63a5\u5199\u5728triggerEvent\u7684\u53c2\u6570\u91cc\u5373\u53ef\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong><span style=\"font-size: 18px\">\u7236\u7ec4\u4ef6\u8c03\u7528\u5b50\u7ec4\u4ef6\u7684\u65b9\u6cd5<\/span><\/strong><\/p>\n<pre>&lt;childele&gt;&lt;\/childele&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7236\u7ec4\u4ef6\u7684 onReady \u751f\u547d\u5468\u671f\u4e2d\u83b7\u53d6 childEle \u5143\u7d20<\/p>\n<pre>onReady(){\n\tthis.childEle&nbsp;=&nbsp;this.selectComponent('#childEle');\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7236\u7ec4\u4ef6\u7684\u70b9\u51fb\u4e8b\u4ef6 childF \u8c03\u7528\u5b50\u7ec4\u4ef6\u7684\u4e8b\u4ef6\uff1a<\/p>\n<pre>&lt;view&gt;\u6211\u662f\u7236\u7ec4\u4ef6\u7684\u70b9\u51fb\u4e8b\u4ef6&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7236\u7ec4\u4ef6\u89e6\u53d1\u5b50\u7ec4\u4ef6\u7684\u65b9\u6cd5\uff1a<\/p>\n<pre>childF(){\n\tthis.childEle.foo()\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u91cc\u7684 foo\u5373\u4e3a\u5b50\u7ec4\u4ef6\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u3010\u76f8\u5173\u5b66\u4e60\u63a8\u8350\uff1a\u3011<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5c0f\u7a0b\u5e8f\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\uff08\u65b9\u6cd5\u6c47\u603b\uff09\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\u4e2d\u600e\u4e48\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u548c\u65b9\u6cd5\u8c03\u7528\uff1f\u4e0b\u9762\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u6c47\u603b\u5206\u4eab\u4e00\u4e9b\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7236\u5b50\u7ec4\u4ef6\u4f20\u503c\u53ca\u65b9\u6cd5\u8c03\u7528\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9\uff01 \u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5c01\u88c5 \u6ce8\u518c\u4e00\u4e2a tab \u7ec4\u4ef6 \u5728 components \u6587\u4ef6\u5939\u4e0b\uff0c\u521b\u5efa\u4e00\u4e2atabs\u6587\u4ef6\u5939\uff0c\u70b9\u51fbtabs\u53f3\u5efa\u5c31\u80fd\u770b\u5230\u4e00\u4e2a\u65b0\u5efacompoent\uff0c\u70b9\u5b8c\u4e00\u4e2a\u65b0\u7684\u7ec4\u4ef6\u5c31\u6ce8\u518c\u6210\u529f\u4e86\u3002 \u7ec4\u4ef6\u4f7f\u7528 \u5728\u9700\u8981\u4f7f\u7528\u8be5\u7ec4\u4ef6\u7684\u9875\u9762\u7684 json \u9875\u9762\u4e0a\u5bfc\u5165\u7ec4\u4ef6\uff0c\u5728 wxml \u4e0b\u50cf HTML \u6807\u7b7e\u4e00\u6837\u4f7f\u7528\u5c31\u597d\u4e86\u3002 &lt;tabs&gt;&lt;\/tabs&gt; \u767b\u5f55\u540e\u590d\u5236 \u4ec0\u4e48\u662f\u7236\u7ec4\u4ef6\uff0c\u4ec0\u4e48\u662f\u5b50\u7ec4\u4ef6\uff1f\u7236\u7ec4\u4ef6\u5c31\u662f\u5728\u9875\u9762\u4e2d\u9700\u8981\u5f15\u5165\u5176\u4ed6\u7684\u7ec4\u4ef6\u7684\u7ec4\u4ef6\uff0c\u800c\u5b50\u7ec4\u4ef6\u5c31\u662f\u5f15\u5165\u7684\u7ec4\u4ef6\u3002\u7236\u5411\u5b50\u4f20\u9012\u6570\u503c\uff0c\u662f\u901a\u8fc7\u5c5e\u6027\u7684\u65b9\u5f0f\u6765\u4f20\u503c\uff0c\u800c\u5b50\u5411\u7236\u4f20\u503c\u8fd8\u8981\u901a\u8fc7\u65b9\u6cd5\u7684\u65b9\u5f0f\u6765\u4f20\u503c\u3002 \u7236\u7ec4\u4ef6\u5411\u5b50\u7ec4\u4ef6\u4f20\u503c \u7236\u7ec4\u4ef6\u901a\u8fc7\u5c5e\u6027\u4f20\u503c &lt;childele&gt;&lt;\/childele&gt; \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u5b50\u7ec4\u4ef6\u901a\u8fc7properties\u63a5\u6536\uff1a properties:&nbsp;{ childParams:&nbsp;{&nbsp;type:&nbsp;String&nbsp;} } \u767b\u5f55\u540e\u590d\u5236 \u5b50\u7ec4\u4ef6\u8c03\u7528\u7236\u7ec4\u4ef6\u65b9\u6cd5 \u8fd9\u4e2a\u65b9\u6cd5\u4e5f\u53ef\u4ee5\u7406\u89e3\u4e3a\u5b50\u7ec4\u4ef6\u5411\u7236\u7ec4\u4ef6\u4f20\u9012\u53c2\u6570\u7684\u65b9\u6cd5\u3002 \u7236\u7ec4\u4ef6\u5b9a\u4e49\u65b9\u6cd5\uff0cchildFun\u662f\u5b50\u7ec4\u4ef6\u4e2d\u7684\u65b9\u6cd5\u540d\uff0cfun\u662f\u7236\u7ec4\u4ef6\u4e2d\u7684\u65b9\u6cd5\u540d\u3002\u6211\u4eec\u901a\u8fc7chidlFun\u6765\u8c03\u7528fun\u3002 &lt;childele&gt;&lt;\/childele&gt; \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u7236\u7ec4\u4ef6\u65b9\u6cd5\uff1a childFun(e){ console.log(&#8216;\u6211\u662f\u7236\u7ec4\u4ef6\u7684\u65b9\u6cd5&#8217;,&nbsp;e) } \u767b\u5f55\u540e\u590d\u5236 \u5f53\u70b9\u51fb\u5b50\u7ec4\u4ef6\u7684\u6309\u94ae\u6267\u884c clickFun \u65f6\u8c03\u7528\u7236\u7ec4\u4ef6\u7684\u65b9\u6cd5 clickFun(){ this.triggerEvent(&#8216;childFun&#8217;);\/\/\u5982\u679c\u9700\u8981\u4f20\u9012\u53c2\u6570\uff0c\u76f4\u63a5\u5199\u5728triggerEvent\u7684\u53c2\u6570\u91cc\u5373\u53ef } \u767b\u5f55\u540e\u590d\u5236 \u7236\u7ec4\u4ef6\u8c03\u7528\u5b50\u7ec4\u4ef6\u7684\u65b9\u6cd5 &lt;childele&gt;&lt;\/childele&gt; \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u7236\u7ec4\u4ef6\u7684 [&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-34151","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34151","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=34151"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/34151\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=34151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=34151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=34151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}