{"id":4628,"date":"2023-01-04T16:55:41","date_gmt":"2023-01-04T08:55:41","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=4628"},"modified":"2023-01-04T16:55:41","modified_gmt":"2023-01-04T08:55:41","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8react%e7%b5%84%e4%bb%b6%e5%b5%8c%e5%a5%97%e8%b7%af%e7%94%b1-2","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/react-js\/%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8react%e7%b5%84%e4%bb%b6%e5%b5%8c%e5%a5%97%e8%b7%af%e7%94%b1-2\/","title":{"rendered":"\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528React\u7d44\u4ef6\u5d4c\u5957\u8def\u7531"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"React, React \u7d44\u4ef6\u5d4c\u5957\u8def\u7531\"><\/p>\n<h1>React \u7d44\u4ef6\u5d4c\u5957\u8def\u7531<\/h1>\n<p>React \u7d44\u4ef6\u5d4c\u5957\u8def\u7531\u662f\u4e00\u7a2e\u4f7f\u7528 React.js \u5efa\u7acb\u8def\u7531\u7684\u65b9\u5f0f\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u8def\u7531\u5206\u914d\u5230\u4e0d\u540c\u7684\u7d44\u4ef6\u4e2d\uff0c\u4ee5\u66f4\u6709\u6548\u7387\u7684\u65b9\u5f0f\u7ba1\u7406\u8def\u7531\u3002<\/p>\n<p>React \u7d44\u4ef6\u5d4c\u5957\u8def\u7531\u7684\u57fa\u672c\u539f\u7406\u662f\uff0c\u5c07\u8def\u7531\u5206\u914d\u5230\u4e0d\u540c\u7684\u7d44\u4ef6\u4e2d\uff0c\u6bcf\u500b\u7d44\u4ef6\u90fd\u6709\u81ea\u5df1\u7684\u8def\u7531\uff0c\u800c\u4e14\u53ef\u4ee5\u5d4c\u5957\u5728\u5176\u4ed6\u7d44\u4ef6\u4e2d\u3002\u9019\u6a23\u4e00\u4f86\uff0c\u958b\u767c\u8005\u5c31\u53ef\u4ee5\u66f4\u6709\u6548\u7387\u7684\u7ba1\u7406\u8def\u7531\uff0c\u4e26\u4e14\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u5c07\u8def\u7531\u8207\u7d44\u4ef6\u9032\u884c\u5c0d\u61c9\u3002<\/p>\n<p>\u8981\u4f7f\u7528 React \u7d44\u4ef6\u5d4c\u5957\u8def\u7531\uff0c\u958b\u767c\u8005\u9996\u5148\u9700\u8981\u5b89\u88dd <code>react-router-dom<\/code> \u5957\u4ef6\uff0c\u7136\u5f8c\u5728\u7d44\u4ef6\u4e2d\u4f7f\u7528 <code>&lt;Route&gt;<\/code> \u6a19\u7c64\u4f86\u5b9a\u7fa9\u8def\u7531\uff0c\u4e26\u5c07\u8def\u7531\u5206\u914d\u5230\u4e0d\u540c\u7684\u7d44\u4ef6\u4e2d\u3002<\/p>\n<pre class=\"brush: javascript\">\nimport { BrowserRouter as Router, Route } from 'react-router-dom';\n\nconst App = () => (\n  <Router>\n    <div>\n      <Route exact path=\"\/\" component={Home} \/>\n      <Route path=\"\/about\" component={About} \/>\n      <Route path=\"\/contact\" component={Contact} \/>\n    <\/div>\n  <\/Router>\n);\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 <code>&lt;Route&gt;<\/code> \u6a19\u7c64\u4f86\u5b9a\u7fa9\u4e09\u500b\u4e0d\u540c\u7684\u8def\u7531\uff0c\u5206\u5225\u5c0d\u61c9\u5230\u4e09\u500b\u4e0d\u540c\u7684\u7d44\u4ef6\uff0c\u4e5f\u5c31\u662f <code>Home<\/code>\u3001<code>About<\/code> \u548c <code>Contact<\/code>\u3002<\/p>\n<p>\u6b64\u5916\uff0cReact \u7d44\u4ef6\u5d4c\u5957\u8def\u7531\u9084\u53ef\u4ee5\u652f\u6301\u5d4c\u5957\u8def\u7531\uff0c\u4e5f\u5c31\u662f\u53ef\u4ee5\u5c07\u4e00\u500b\u8def\u7531\u5206\u914d\u5230\u53e6\u4e00\u500b\u7d44\u4ef6\u4e2d\uff0c\u4ee5\u66f4\u6709\u6548\u7387\u7684\u65b9\u5f0f\u7ba1\u7406\u8def\u7531\u3002<\/p>\n<pre class=\"brush: javascript\">\nimport { BrowserRouter as Router, Route } from 'react-router-dom';\n\nconst App = () => (\n  <Router>\n    <div>\n      <Route exact path=\"\/\" component={Home} \/>\n      <Route path=\"\/about\" component={About}>\n        <Route path=\"\/about\/team\" component={Team} \/>\n        <Route path=\"\/about\/history\" component={History} \/>\n      <\/Route>\n      <Route path=\"\/contact\" component={Contact} \/>\n    <\/div>\n  <\/Router>\n);\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u5c07 <code>Team<\/code> \u548c <code>History<\/code> \u5169\u500b\u7d44\u4ef6\u5206\u914d\u5230 <code>About<\/code> \u7d44\u4ef6\u4e2d\uff0c\u9019\u6a23\u4e00\u4f86\uff0c\u958b\u767c\u8005\u5c31\u53ef\u4ee5\u66f4\u6709\u6548\u7387\u7684\u7ba1\u7406\u8def\u7531\uff0c\u4e26\u4e14\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u5c07\u8def\u7531\u8207\u7d44\u4ef6\u9032\u884c\u5c0d\u61c9\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u53e6\u5916\uff0cReact \u7d44\u4ef6\u5d4c\u5957\u8def\u7531\u9084\u53ef\u4ee5\u652f\u6301\u52d5\u614b\u8def\u7531\uff0c\u4e5f\u5c31\u662f\u53ef\u4ee5\u4f7f\u7528 <code>&lt;Route&gt;<\/code> \u6a19\u7c64\u7684 <code>render<\/code> \u5c6c\u6027\u4f86\u6e32\u67d3\u52d5\u614b\u8def\u7531\u3002<\/p>\n<pre class=\"brush: javascript\">\nimport { BrowserRouter as Router, Route } from 'react-router-dom';\n\nconst App = () => (\n  <Router>\n    <div>\n      <Route exact path=\"\/\" component={Home} \/>\n      <Route path=\"\/about\" component={About}>\n        <Route path=\"\/about\/team\" component={Team} \/>\n        <Route path=\"\/about\/history\" component={History} \/>\n      <\/Route>\n      <Route path=\"\/contact\" component={Contact} \/>\n      <Route\n        path=\"\/user\/:id\"\n        render={props => <User {...props} \/>}\n      \/>\n    <\/div>\n  <\/Router>\n);\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 <code>&lt;Route&gt;<\/code> \u6a19\u7c64\u7684 <code>render<\/code> \u5c6c\u6027\u4f86\u6e32\u67d3\u52d5\u614b\u8def\u7531\uff0c\u4e5f\u5c31\u662f <code>\/user\/:id<\/code>\uff0c\u9019\u6a23\u4e00\u4f86\uff0c\u958b\u767c\u8005\u5c31\u53ef\u4ee5\u66f4\u6709\u6548\u7387\u7684\u7ba1\u7406\u52d5\u614b\u8def\u7531\uff0c\u4e26\u4e14\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u5c07\u8def\u7531\u8207\u7d44\u4ef6\u9032\u884c\u5c0d\u61c9\u3002<\/p>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0cReact \u7d44\u4ef6\u5d4c\u5957\u8def\u7531\u662f\u4e00\u7a2e\u4f7f\u7528 React.js \u5efa\u7acb\u8def\u7531\u7684\u65b9\u5f0f\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u8def\u7531\u5206\u914d\u5230\u4e0d\u540c\u7684\u7d44\u4ef6\u4e2d\uff0c\u4ee5\u66f4\u6709\u6548\u7387\u7684\u65b9\u5f0f\u7ba1\u7406\u8def\u7531\uff0c\u4e26\u4e14\u53ef\u4ee5\u652f\u6301\u5d4c\u5957\u8def\u7531\u548c\u52d5\u614b\u8def\u7531\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528React\u7d44\u4ef6\u5d4c\u5957\u8def\u7531\uff0c\u53ef\u4ee5\u8b93\u4f60\u66f4\u6709\u6548\u7387\u5730\u958b\u767c\u51fa\u66f4\u591a\u529f\u80fd\u7684\u61c9\u7528\u7a0b\u5f0f\uff0c\u8b93\u4f60\u7684\u61c9\u7528\u7a0b\u5f0f\u66f4\u5bb9\u6613\u7dad\u8b77\u548c\u64f4\u5c55\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-4628","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-1cE","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4628","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=4628"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4628\/revisions"}],"predecessor-version":[{"id":4629,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4628\/revisions\/4629"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=4628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=4628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=4628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}