{"id":53003,"date":"2024-12-03T17:03:26","date_gmt":"2024-12-03T09:03:26","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53003\/"},"modified":"2024-12-03T17:03:26","modified_gmt":"2024-12-03T09:03:26","slug":"react%e7%bb%84%e4%bb%b6%e6%8e%a5%e6%94%b6%e7%9b%b8%e5%90%8cprops%e4%bc%9a%e8%b7%b3%e8%bf%87%e6%b8%b2%e6%9f%93%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53003\/","title":{"rendered":"React\u7ec4\u4ef6\u63a5\u6536\u76f8\u540cprops\u4f1a\u8df3\u8fc7\u6e32\u67d3\u5417\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>React\u7ec4\u4ef6\u63a5\u6536\u76f8\u540cprops\u4f1a\u8df3\u8fc7\u6e32\u67d3\u5417\uff1f<\/h1>\n<p>\u5728IT\u884c\u4e1a\u8fd9\u4e2a\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u5f88\u5feb\u7684\u884c\u4e1a\uff0c\u53ea\u6709\u4e0d\u505c\u6b62\u7684\u5b66\u4e60\uff0c\u624d\u4e0d\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u5982\u679c\u4f60\u662f\u6587\u7ae0\u5b66\u4e60\u8005\uff0c\u90a3\u4e48\u672c\u6587\u300aReact\u7ec4\u4ef6\u63a5\u6536\u76f8\u540cprops\u4f1a\u8df3\u8fc7\u6e32\u67d3\u5417\uff1f\u300b\u5c31\u5f88\u9002\u5408\u4f60\uff01\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u5305\u62ec##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241125\/173252127067442d36554ce.jpg\" class=\"aligncenter\" title=\"React\u7ec4\u4ef6\u63a5\u6536\u76f8\u540cprops\u4f1a\u8df3\u8fc7\u6e32\u67d3\u5417\uff1f\u63d2\u56fe\" alt=\"React\u7ec4\u4ef6\u63a5\u6536\u76f8\u540cprops\u4f1a\u8df3\u8fc7\u6e32\u67d3\u5417\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>react \u4e2d\u7ec4\u4ef6\u63a5\u6536\u76f8\u540c props \u662f\u5426\u8df3\u8fc7\u6e32\u67d3\uff1f<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>react \u7ec4\u4ef6 &lt;p&gt;&lt;\/p&gt;shippingform \u63a5\u6536\u76f8\u540c\u7684 props\uff0c\u662f\u5426\u4f1a\u8df3\u8fc7\u6e32\u67d3\uff1f\u5b9e\u9645\u6d4b\u8bd5\u53d1\u73b0\u7ec4\u4ef6\u5e76\u672a\u8df3\u8fc7\u6e32\u67d3\u3002<\/p>\n<p><strong>\u90e8\u5206\u7b54\u6848\uff1a<\/strong><\/p>\n<p>\u4f60\u6240\u770b\u5230\u7684\u4fe1\u606f\u5e76\u4e0d\u5b8c\u6574\u3002\u4e3a\u4e86\u9632\u6b62\u91cd\u65b0\u6e32\u67d3\uff0c\u8fd8\u9700\u8981\u5c06\u5b50\u7ec4\u4ef6\u5305\u88f9\u5728 react.memo \u4e2d\u3002<\/p>\n<p><strong>\u5b8c\u6574\u7b54\u6848\uff1a<\/strong><\/p>\n<p>react \u7ec4\u4ef6\u672c\u8eab\u4e0d\u4f1a\u5224\u65ad\u4f20\u5165\u7684 props \u662f\u5426\u76f8\u540c\u3002react.memo \u7528\u4e8e\u68c0\u67e5\u4f20\u5165 props \u7684\u76f8\u7b49\u6027\uff0c\u5e76\u5728\u68c0\u6d4b\u5230\u672a\u66f4\u6539\u65f6\u8df3\u8fc7\u6e32\u67d3\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u5b9e\u73b0\u4e0a\u8ff0\u6548\u679c\uff0c\u4f60\u7684\u5b50\u7ec4\u4ef6\u5fc5\u987b\u88ab react.memo \u5305\u88f9\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>import { memo } from \"react\";\n\nconst MyComponent = memo((props) =&gt; {\n  \/\/ \u4f60\u7684\u7ec4\u4ef6\u4ee3\u7801\n});<\/pre>\n<p>\u5305\u88f9\u5b50\u7ec4\u4ef6\u540e\uff0creact \u5c06\u5728\u63a5\u6536\u76f8\u540c props \u65f6\u8df3\u8fc7\u5176\u6e32\u67d3\u3002<\/p>\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   Vue3 computed\u4e2d\u4f7f\u7528\u6570\u7ec4\u5bfc\u81f4\u6808\u6ea2\u51fa\uff1a\u5982\u4f55\u907f\u514d\u76f8\u4e92\u4f9d\u8d56\u7684\u8ba1\u7b97\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>React\u7ec4\u4ef6\u63a5\u6536\u76f8\u540cprops\u4f1a\u8df3\u8fc7\u6e32\u67d3\u5417\uff1f \u5728IT\u884c\u4e1a\u8fd9\u4e2a\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u5f88\u5feb\u7684\u884c\u4e1a\uff0c\u53ea\u6709\u4e0d\u505c\u6b62\u7684\u5b66\u4e60\uff0c\u624d\u4e0d\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u5982\u679c\u4f60\u662f\u6587\u7ae0\u5b66\u4e60\u8005\uff0c\u90a3\u4e48\u672c\u6587\u300aReact\u7ec4\u4ef6\u63a5\u6536\u76f8\u540cprops\u4f1a\u8df3\u8fc7\u6e32\u67d3\u5417\uff1f\u300b\u5c31\u5f88\u9002\u5408\u4f60\uff01\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u5305\u62ec##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01 react \u4e2d\u7ec4\u4ef6\u63a5\u6536\u76f8\u540c props \u662f\u5426\u8df3\u8fc7\u6e32\u67d3\uff1f \u95ee\u9898\uff1a react \u7ec4\u4ef6 &lt;p&gt;&lt;\/p&gt;shippingform \u63a5\u6536\u76f8\u540c\u7684 props\uff0c\u662f\u5426\u4f1a\u8df3\u8fc7\u6e32\u67d3\uff1f\u5b9e\u9645\u6d4b\u8bd5\u53d1\u73b0\u7ec4\u4ef6\u5e76\u672a\u8df3\u8fc7\u6e32\u67d3\u3002 \u90e8\u5206\u7b54\u6848\uff1a \u4f60\u6240\u770b\u5230\u7684\u4fe1\u606f\u5e76\u4e0d\u5b8c\u6574\u3002\u4e3a\u4e86\u9632\u6b62\u91cd\u65b0\u6e32\u67d3\uff0c\u8fd8\u9700\u8981\u5c06\u5b50\u7ec4\u4ef6\u5305\u88f9\u5728 react.memo \u4e2d\u3002 \u5b8c\u6574\u7b54\u6848\uff1a react \u7ec4\u4ef6\u672c\u8eab\u4e0d\u4f1a\u5224\u65ad\u4f20\u5165\u7684 props \u662f\u5426\u76f8\u540c\u3002react.memo \u7528\u4e8e\u68c0\u67e5\u4f20\u5165 props \u7684\u76f8\u7b49\u6027\uff0c\u5e76\u5728\u68c0\u6d4b\u5230\u672a\u66f4\u6539\u65f6\u8df3\u8fc7\u6e32\u67d3\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u5b9e\u73b0\u4e0a\u8ff0\u6548\u679c\uff0c\u4f60\u7684\u5b50\u7ec4\u4ef6\u5fc5\u987b\u88ab react.memo \u5305\u88f9\u3002 \u793a\u4f8b\uff1a import { memo } from &#8220;react&#8221;; const MyComponent = memo((props) =&gt; { \/\/ \u4f60\u7684\u7ec4\u4ef6\u4ee3\u7801 }); \u5305\u88f9\u5b50\u7ec4\u4ef6\u540e\uff0creact \u5c06\u5728\u63a5\u6536\u76f8\u540c props \u65f6\u8df3\u8fc7\u5176\u6e32\u67d3\u3002 \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~ Vue3 computed\u4e2d\u4f7f\u7528\u6570\u7ec4\u5bfc\u81f4\u6808\u6ea2\u51fa\uff1a\u5982\u4f55\u907f\u514d\u76f8\u4e92\u4f9d\u8d56\u7684\u8ba1\u7b97\uff1f<\/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-53003","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53003","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=53003"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53003\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}