{"id":53038,"date":"2024-12-03T14:03:34","date_gmt":"2024-12-03T06:03:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53038\/"},"modified":"2024-12-03T14:03:34","modified_gmt":"2024-12-03T06:03:34","slug":"jsx%e5%87%bd%e6%95%b0%e4%b8%ad%e6%b8%b2%e6%9f%93%e7%bb%84%e4%bb%b6%e6%97%b6%ef%bc%8c%e4%b8%ba%e4%bb%80%e4%b9%88rendercomdom%e6%97%a0%e6%b3%95%e6%ad%a3%e7%a1%ae%e6%b8%b2%e6%9f%93%e7%bb%84%e4%bb%b6-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53038\/","title":{"rendered":"JSX\u51fd\u6570\u4e2d\u6e32\u67d3\u7ec4\u4ef6\u65f6\uff0c\u4e3a\u4ec0\u4e48renderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>JSX\u51fd\u6570\u4e2d\u6e32\u67d3\u7ec4\u4ef6\u65f6\uff0c\u4e3a\u4ec0\u4e48renderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f <\/h1>\n<p>\u600e\u4e48\u5165\u95e8\u6587\u7ae0\u7f16\u7a0b\uff1f\u9700\u8981\u5b66\u4e60\u54ea\u4e9b\u77e5\u8bc6\u70b9\uff1f\u8fd9\u662f\u65b0\u624b\u4eec\u521a\u63a5\u89e6\u7f16\u7a0b\u65f6\u5e38\u89c1\u7684\u95ee\u9898\uff1b\u4e0b\u9762\u7c73\u4e91\u5c31\u6765\u7ed9\u5927\u5bb6\u6574\u7406\u5206\u4eab\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u591f\u7ed9\u521d\u5b66\u8005\u4e00\u4e9b\u5e2e\u52a9\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u4ecb\u7ecd\u300aJSX\u51fd\u6570\u4e2d\u6e32\u67d3\u7ec4\u4ef6\u65f6\uff0c\u4e3a\u4ec0\u4e48renderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f \u300b\uff0c\u6d89\u53ca\u5230\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u6536\u85cf\u4e00\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241125\/173254665867449062b28b9.jpg\" class=\"aligncenter\" title=\"JSX\u51fd\u6570\u4e2d\u6e32\u67d3\u7ec4\u4ef6\u65f6\uff0c\u4e3a\u4ec0\u4e48renderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f\u63d2\u56fe\" alt=\"JSX\u51fd\u6570\u4e2d\u6e32\u67d3\u7ec4\u4ef6\u65f6\uff0c\u4e3a\u4ec0\u4e48renderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>JSX\u51fd\u6570\u4e2d\u5982\u4f55\u6e32\u67d3\u7ec4\u4ef6<\/strong><\/p>\n<p>\u5728React\u4e2d\uff0cJSX\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u5b9a\u4e49\u7ec4\u4ef6\u3002\u5176\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528JSX\u8bed\u6cd5\u6765\u6e32\u67d3\u53e6\u4e00\u4e2a\u7ec4\u4ef6\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u4e2d\uff0c\u4e3a\u4ec0\u4e48renderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f<\/p>\n<pre>import React from \"react\";\nimport Com from \".\/com\";\n\nconst Text = () =&gt; {\n  const renderDom = () =&gt; {\n    return &lt;div&gt;222222&lt;\/div&gt;;\n  };\n\n  const renderComDom = () =&gt; {\n    return &lt;Com \/&gt;;\n  };\n\n  return (\n    &lt;div&gt;\n      {renderDom()}\n      {renderComDom()}\n    &lt;\/div&gt;\n  );\n};\n\nexport default Text;<\/pre>\n<p><strong>\u7b54\u6848\uff1a<\/strong><\/p>\n<p>\u8be5\u95ee\u9898\u53ef\u80fd\u662f\u56e0\u4e3aCom\u7ec4\u4ef6\u8fd4\u56de\u4e86\u4e00\u4e2a\u7a7a\u6807\u7b7e\u3002\u5f53JSX\u51fd\u6570\u4e2d\u8fd4\u56de\u4e00\u4e2a\u7a7a\u6807\u7b7e\u65f6\uff0cReact\u5c06\u5728\u6e32\u67d3\u8fc7\u7a0b\u4e2d\u5c06\u5176\u5ffd\u7565\u3002\u56e0\u6b64\uff0crenderComDom\u8fd4\u56de\u7684\u7a7a\u6807\u7b7e\u5728\u6e32\u67d3\u8fc7\u7a0b\u4e2d\u88ab\u5ffd\u7565\uff0c\u5bfc\u81f4\u7ec4\u4ef6\u672a\u88ab\u6e32\u67d3\u51fa\u6765\u3002<\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u786e\u4fddCom\u7ec4\u4ef6\u59cb\u7ec8\u8fd4\u56de\u4e00\u4e2a\u6709\u6548\u7684JSX\u5143\u7d20\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>\/\/ \u5728Com.js\u4e2d\n\nconst Com = () =&gt; {\n  return &lt;div&gt;\u6211\u662fCom\u7ec4\u4ef6&lt;\/div&gt;;\n};<\/pre>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5982\u4f55\u901a\u8fc7\u5b57\u7b26\u4e32\u4e2d\u7684\u6570\u5b57\u5bf9 Python \u5217\u8868\u8fdb\u884c\u6392\u5e8f\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>JSX\u51fd\u6570\u4e2d\u6e32\u67d3\u7ec4\u4ef6\u65f6\uff0c\u4e3a\u4ec0\u4e48renderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f \u600e\u4e48\u5165\u95e8\u6587\u7ae0\u7f16\u7a0b\uff1f\u9700\u8981\u5b66\u4e60\u54ea\u4e9b\u77e5\u8bc6\u70b9\uff1f\u8fd9\u662f\u65b0\u624b\u4eec\u521a\u63a5\u89e6\u7f16\u7a0b\u65f6\u5e38\u89c1\u7684\u95ee\u9898\uff1b\u4e0b\u9762\u7c73\u4e91\u5c31\u6765\u7ed9\u5927\u5bb6\u6574\u7406\u5206\u4eab\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u591f\u7ed9\u521d\u5b66\u8005\u4e00\u4e9b\u5e2e\u52a9\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u4ecb\u7ecd\u300aJSX\u51fd\u6570\u4e2d\u6e32\u67d3\u7ec4\u4ef6\u65f6\uff0c\u4e3a\u4ec0\u4e48renderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f \u300b\uff0c\u6d89\u53ca\u5230\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u6536\u85cf\u4e00\u4e0b JSX\u51fd\u6570\u4e2d\u5982\u4f55\u6e32\u67d3\u7ec4\u4ef6 \u5728React\u4e2d\uff0cJSX\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u5b9a\u4e49\u7ec4\u4ef6\u3002\u5176\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528JSX\u8bed\u6cd5\u6765\u6e32\u67d3\u53e6\u4e00\u4e2a\u7ec4\u4ef6\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a \u95ee\u9898\uff1a \u4ee5\u4e0b\u4ee3\u7801\u4e2d\uff0c\u4e3a\u4ec0\u4e48renderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f import React from &#8220;react&#8221;; import Com from &#8220;.\/com&#8221;; const Text = () =&gt; { const renderDom = () =&gt; { return &lt;div&gt;222222&lt;\/div&gt;; }; const renderComDom = () =&gt; { return &lt;Com \/&gt;; }; return ( &lt;div&gt; {renderDom()} {renderComDom()} &lt;\/div&gt; ); }; export default Text; \u7b54\u6848\uff1a \u8be5\u95ee\u9898\u53ef\u80fd\u662f\u56e0\u4e3aCom\u7ec4\u4ef6\u8fd4\u56de\u4e86\u4e00\u4e2a\u7a7a\u6807\u7b7e\u3002\u5f53JSX\u51fd\u6570\u4e2d\u8fd4\u56de\u4e00\u4e2a\u7a7a\u6807\u7b7e\u65f6\uff0cReact\u5c06\u5728\u6e32\u67d3\u8fc7\u7a0b\u4e2d\u5c06\u5176\u5ffd\u7565\u3002\u56e0\u6b64\uff0crenderComDom\u8fd4\u56de\u7684\u7a7a\u6807\u7b7e\u5728\u6e32\u67d3\u8fc7\u7a0b\u4e2d\u88ab\u5ffd\u7565\uff0c\u5bfc\u81f4\u7ec4\u4ef6\u672a\u88ab\u6e32\u67d3\u51fa\u6765\u3002 \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u786e\u4fddCom\u7ec4\u4ef6\u59cb\u7ec8\u8fd4\u56de\u4e00\u4e2a\u6709\u6548\u7684JSX\u5143\u7d20\uff0c\u4f8b\u5982\uff1a \/\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-53038","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53038","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=53038"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53038\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}