{"id":27300,"date":"2024-11-24T17:22:05","date_gmt":"2024-11-24T09:22:05","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27300\/"},"modified":"2024-11-24T17:22:05","modified_gmt":"2024-11-24T09:22:05","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-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27300\/","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><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173122651450829.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\uff0crenderComDom\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJSX\u51fd\u6570\u4e2d\u6e32\u67d3\u7ec4\u4ef6\u65f6\uff0crenderComDom\u65e0\u6cd5\u6b63\u786e\u6e32\u67d3\u7ec4\u4ef6\uff0c\u800crenderDom\u53ef\u4ee5\uff1f\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>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\uff0crenderComDom\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; \u767b\u5f55\u540e\u590d\u5236 \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 \/\/ \u5728Com.js\u4e2d const [&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-27300","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27300","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=27300"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27300\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}