{"id":4674,"date":"2023-01-04T17:28:22","date_gmt":"2023-01-04T09:28:22","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=4674"},"modified":"2023-01-04T17:28:22","modified_gmt":"2023-01-04T09:28:22","slug":"%e8%a7%a3%e6%b1%bareact-js%e4%b8%ad%e7%9a%84%e3%80%8cinvalidvalueforpropcomponentontag%e3%80%8d%e9%8c%af%e8%aa%a4","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/react-js\/%e8%a7%a3%e6%b1%bareact-js%e4%b8%ad%e7%9a%84%e3%80%8cinvalidvalueforpropcomponentontag%e3%80%8d%e9%8c%af%e8%aa%a4\/","title":{"rendered":"\u89e3\u6c7aReact.js\u4e2d\u7684\u300cInvalidvalueforpropcomponenton<Route>tag\u300d\u932f\u8aa4"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"React.js, Error, Invalid value, prop component, Route tag, string, function\"><\/p>\n<h1>\u89e3\u6c7a React.js &#8220;Error: Invalid value for prop component on <Route> tag&#8221; \u7684\u932f\u8aa4<\/h1>\n<p>React.js \u662f\u4e00\u500b\u7528\u65bc\u69cb\u5efa\u7528\u6236\u754c\u9762\u7684 JavaScript \u5eab\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5feb\u901f\u69cb\u5efa\u529f\u80fd\u5f37\u5927\u7684\u61c9\u7528\u7a0b\u5e8f\u3002\u7136\u800c\uff0c\u5728\u4f7f\u7528 React.js \u6642\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u9047\u5230\u4e00\u4e9b\u554f\u984c\uff0c\u5176\u4e2d\u4e00\u500b\u662f &#8220;Error: Invalid value for prop component on <Route> tag&#8221; \u932f\u8aa4\u3002<\/p>\n<p>\u9019\u500b\u932f\u8aa4\u7684\u539f\u56e0\u662f\u56e0\u70ba\u958b\u767c\u8005\u5728\u4f7f\u7528 <Route> \u6a19\u7c64\u6642\uff0c\u6c92\u6709\u6b63\u78ba\u5730\u50b3\u905e prop component \u53c3\u6578\u3002prop component \u53c3\u6578\u61c9\u8a72\u662f\u4e00\u500b\u5b57\u7b26\u4e32\u6216\u51fd\u6578\uff0c\u4f46\u662f\u958b\u767c\u8005\u53ef\u80fd\u6703\u5fd8\u8a18\u50b3\u905e\u9019\u500b\u53c3\u6578\uff0c\u6216\u8005\u50b3\u905e\u7684\u53c3\u6578\u4e0d\u662f\u5b57\u7b26\u4e32\u6216\u51fd\u6578\uff0c\u5c0e\u81f4\u51fa\u73fe\u9019\u500b\u932f\u8aa4\u3002<\/p>\n<p>\u8981\u89e3\u6c7a\u9019\u500b\u554f\u984c\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u5617\u8a66\u5169\u7a2e\u65b9\u6cd5\uff1a<\/p>\n<h2>1. \u522a\u9664 prop component \u53c3\u6578<\/h2>\n<p>\u5982\u679c\u958b\u767c\u8005\u4e0d\u9700\u8981\u50b3\u905e prop component \u53c3\u6578\uff0c\u90a3\u9ebc\u4ed6\u5011\u53ef\u4ee5\u76f4\u63a5\u522a\u9664\u9019\u500b\u53c3\u6578\uff0c\u9019\u6a23\u5c31\u53ef\u4ee5\u89e3\u6c7a\u9019\u500b\u554f\u984c\u3002<\/p>\n<pre class=\"brush: javascript\">\n<Route path=\"\/about\" \/>\n<\/pre>\n<h2>2. \u50b3\u905e\u5b57\u7b26\u4e32\u6216\u51fd\u6578<\/h2>\n<p>\u5982\u679c\u958b\u767c\u8005\u9700\u8981\u50b3\u905e prop component \u53c3\u6578\uff0c\u90a3\u9ebc\u4ed6\u5011\u53ef\u4ee5\u50b3\u905e\u4e00\u500b\u5b57\u7b26\u4e32\u6216\u51fd\u6578\uff0c\u4ee5\u6b64\u4f86\u89e3\u6c7a\u9019\u500b\u554f\u984c\u3002<\/p>\n<pre class=\"brush: javascript\">\n<Route path=\"\/about\" component={About} \/>\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u5011\u50b3\u905e\u4e86\u4e00\u500b\u5b57\u7b26\u4e32\uff0c\u5b83\u6307\u5411\u4e00\u500b\u53eb\u505a About \u7684\u7d44\u4ef6\u3002<\/p>\n<p>\u901a\u904e\u4ee5\u4e0a\u5169\u7a2e\u65b9\u6cd5\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u89e3\u6c7a React.js &#8220;Error: Invalid value for prop component on <Route> tag&#8221; \u932f\u8aa4\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u96d6\u7136\u9019\u500b\u932f\u8aa4\u770b\u8d77\u4f86\u5f88\u7c21\u55ae\uff0c\u4f46\u662f\u5982\u679c\u958b\u767c\u8005\u6c92\u6709\u6b63\u78ba\u5730\u50b3\u905e prop component \u53c3\u6578\uff0c\u5c31\u6703\u5c0e\u81f4\u51fa\u73fe\u9019\u500b\u932f\u8aa4\u3002\u56e0\u6b64\uff0c\u958b\u767c\u8005\u61c9\u8a72\u7262\u8a18\u9019\u500b\u932f\u8aa4\uff0c\u4ee5\u514d\u5728\u958b\u767c React.js \u61c9\u7528\u7a0b\u5e8f\u6642\u51fa\u73fe\u554f\u984c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u89e3\u6c7aReact.js\u4e2d\u7684\u300cInvalidvalueforpropcomponenton<Route>tag\u300d\u932f\u8aa4\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u6709\u7528\u7684\u6280\u5de7\uff0c\u4ee5\u4fbf\u958b\u767c\u8005\u80fd\u5920\u66f4\u6709\u6548\u5730\u89e3\u6c7a\u6b64\u985e\u554f\u984c\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-4674","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-1do","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4674","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=4674"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4674\/revisions"}],"predecessor-version":[{"id":4675,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4674\/revisions\/4675"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=4674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=4674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=4674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}