{"id":4520,"date":"2023-01-04T15:53:52","date_gmt":"2023-01-04T07:53:52","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=4520"},"modified":"2023-01-04T15:53:52","modified_gmt":"2023-01-04T07:53:52","slug":"%e5%ad%b8%e7%bf%92react%e8%b3%87%e6%96%99%e7%b9%ab%e7%b5%90props%ef%bc%8c%e8%ae%93%e4%bd%a0%e7%9a%84%e7%b6%b2%e9%a0%81%e6%9b%b4%e5%85%b7%e5%bd%88%e6%80%a7","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/react-js\/%e5%ad%b8%e7%bf%92react%e8%b3%87%e6%96%99%e7%b9%ab%e7%b5%90props%ef%bc%8c%e8%ae%93%e4%bd%a0%e7%9a%84%e7%b6%b2%e9%a0%81%e6%9b%b4%e5%85%b7%e5%bd%88%e6%80%a7\/","title":{"rendered":"\u5b78\u7fd2React\u8cc7\u6599\u7e6b\u7d50(props)\uff0c\u8b93\u4f60\u7684\u7db2\u9801\u66f4\u5177\u5f48\u6027"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"React, \u8cc7\u6599\u7e6b\u7d50, props\"><\/p>\n<h1>React \u8cc7\u6599\u7e6b\u7d50(props)<\/h1>\n<p>React \u8cc7\u6599\u7e6b\u7d50(props)\u662f React \u4e2d\u6700\u91cd\u8981\u7684\u6982\u5ff5\u4e4b\u4e00\uff0c\u5b83\u53ef\u4ee5\u8b93\u4f60\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u50b3\u905e\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u8b93\u4f60\u7684\u61c9\u7528\u7a0b\u5f0f\u66f4\u52a0\u53ef\u64f4\u5145\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u8a73\u7d30\u4ecb\u7d39 React \u8cc7\u6599\u7e6b\u7d50(props)\uff0c\u4e26\u4e14\u63d0\u4f9b\u4e00\u4e9b\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\u4f86\u8b93\u4f60\u66f4\u52a0\u4e86\u89e3\u5b83\u3002<\/p>\n<p><!--more--><\/p>\n<p>React \u8cc7\u6599\u7e6b\u7d50(props)\u662f React \u4e2d\u6700\u91cd\u8981\u7684\u6982\u5ff5\u4e4b\u4e00\uff0c\u5b83\u53ef\u4ee5\u8b93\u4f60\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u50b3\u905e\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u8b93\u4f60\u7684\u61c9\u7528\u7a0b\u5f0f\u66f4\u52a0\u53ef\u64f4\u5145\u3002\u5728 React \u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 props \u4f86\u50b3\u905e\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u5728\u7d44\u4ef6\u4e2d\u4f7f\u7528\u5b83\u5011\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f React \u8cc7\u6599\u7e6b\u7d50(props)<\/h2>\n<p>React \u8cc7\u6599\u7e6b\u7d50(props)\u662f React \u4e2d\u6700\u91cd\u8981\u7684\u6982\u5ff5\u4e4b\u4e00\uff0c\u5b83\u53ef\u4ee5\u8b93\u4f60\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u50b3\u905e\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u8b93\u4f60\u7684\u61c9\u7528\u7a0b\u5f0f\u66f4\u52a0\u53ef\u64f4\u5145\u3002<\/p>\n<h2>\u5982\u4f55\u4f7f\u7528 React \u8cc7\u6599\u7e6b\u7d50(props)<\/h2>\n<p>\u4f7f\u7528 React \u8cc7\u6599\u7e6b\u7d50(props)\u5f88\u7c21\u55ae\uff0c\u4f60\u53ea\u9700\u8981\u5728\u7d44\u4ef6\u4e2d\u5b9a\u7fa9\u4e00\u500b props \u5c6c\u6027\uff0c\u4e26\u4e14\u5c07\u8cc7\u6599\u50b3\u905e\u7d66\u5b83\uff0c\u5c31\u53ef\u4ee5\u5728\u7d44\u4ef6\u4e2d\u4f7f\u7528\u5b83\u3002\u4f8b\u5982\uff0c\u5047\u8a2d\u4f60\u6709\u4e00\u500b\u540d\u70ba <code>MyComponent<\/code> \u7684\u7d44\u4ef6\uff0c\u4e26\u4e14\u5b83\u6709\u4e00\u500b\u540d\u70ba <code>name<\/code> \u7684 props \u5c6c\u6027\uff0c\u4f60\u53ef\u4ee5\u9019\u6a23\u4f7f\u7528\u5b83\uff1a<\/p>\n<pre class=\"brush: javascript\">\nconst MyComponent = (props) => {\n  return <div>Hello, {props.name}!<\/div>;\n};\n\nReactDOM.render(\n  <MyComponent name=\"John\" \/>,\n  document.getElementById('root')\n);\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u5c07 <code>name<\/code> \u7684\u503c\u50b3\u905e\u7d66 <code>MyComponent<\/code> \u7d44\u4ef6\uff0c\u4e26\u4e14\u5728\u7d44\u4ef6\u4e2d\u4f7f\u7528\u5b83\u3002<\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>React \u8cc7\u6599\u7e6b\u7d50(props)\u662f React \u4e2d\u6700\u91cd\u8981\u7684\u6982\u5ff5\u4e4b\u4e00\uff0c\u5b83\u53ef\u4ee5\u8b93\u4f60\u5728\u4e0d\u540c\u7684\u7d44\u4ef6\u4e4b\u9593\u50b3\u905e\u8cc7\u6599\uff0c\u4e26\u4e14\u53ef\u4ee5\u8b93\u4f60\u7684\u61c9\u7528\u7a0b\u5f0f\u66f4\u52a0\u53ef\u64f4\u5145\u3002\u4f7f\u7528 React \u8cc7\u6599\u7e6b\u7d50(props)\u5f88\u7c21\u55ae\uff0c\u4f60\u53ea\u9700\u8981\u5728\u7d44\u4ef6\u4e2d\u5b9a\u7fa9\u4e00\u500b props \u5c6c\u6027\uff0c\u4e26\u4e14\u5c07\u8cc7\u6599\u50b3\u905e\u7d66\u5b83\uff0c\u5c31\u53ef\u4ee5\u5728\u7d44\u4ef6\u4e2d\u4f7f\u7528\u5b83\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2React\u8cc7\u6599\u7e6b\u7d50(props)\uff0c\u53ef\u4ee5\u8b93\u4f60\u7684\u7db2\u9801\u66f4\u5177\u5f48\u6027\uff0c\u8b93\u4f60\u53ef\u4ee5\u66f4\u6709\u6548\u7387\u7684\u64cd\u4f5c\u7db2\u9801\u5143\u4ef6\uff0c\u8b93\u4f60\u7684\u7db2\u9801\u66f4\u52a0\u5b8c\u5584\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[184,183],"tags":[182,181],"class_list":["post-4520","post","type-post","status-publish","format-standard","hentry","category-react","category-react-js","tag-react","tag-react-js"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1aU","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=4520"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4520\/revisions"}],"predecessor-version":[{"id":4521,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4520\/revisions\/4521"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=4520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=4520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=4520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}