{"id":5573,"date":"2023-01-06T09:43:26","date_gmt":"2023-01-06T01:43:26","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5573"},"modified":"2023-01-06T09:43:26","modified_gmt":"2023-01-06T01:43:26","slug":"1-%e4%ba%86%e8%a7%a3%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8react-js%e6%9b%bf%e6%8f%9b%e5%ad%97%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/react-js\/1-%e4%ba%86%e8%a7%a3%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8react-js%e6%9b%bf%e6%8f%9b%e5%ad%97%e4%b8%b2\/","title":{"rendered":"1.\u4e86\u89e3\u5982\u4f55\u5229\u7528React.JS\u66ff\u63db\u5b57\u4e32"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"React.JS, replace\"><\/p>\n<h1>\u4f7f\u7528 React.JS \u4f86\u66ff\u63db\u5b57\u4e32<\/h1>\n<p>React.JS \u662f\u4e00\u500b\u7531 Facebook \u6240\u958b\u767c\u7684 JavaScript \u51fd\u5f0f\u5eab\uff0c\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5feb\u901f\u958b\u767c\u51fa\u9ad8\u54c1\u8cea\u7684\u7db2\u9801\u61c9\u7528\u7a0b\u5f0f\u3002\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c08\u6ce8\u65bc\u61c9\u7528\u7a0b\u5f0f\u7684\u529f\u80fd\uff0c\u800c\u4e0d\u7528\u64d4\u5fc3\u7db2\u9801\u7684\u67b6\u69cb\u548c\u6a23\u5f0f\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528 React.JS \u4f86\u66ff\u63db\u5b57\u4e32\u3002<\/p>\n<h2>\u4f7f\u7528 React.JS \u4f86\u66ff\u63db\u5b57\u4e32<\/h2>\n<p>React.JS \u63d0\u4f9b\u4e86\u4e00\u500b\u53eb\u505a <code>React.replace()<\/code> \u7684\u51fd\u5f0f\uff0c\u53ef\u4ee5\u7528\u4f86\u66ff\u63db\u5b57\u4e32\u4e2d\u7684\u6587\u5b57\u3002\u5b83\u63a5\u53d7\u4e09\u500b\u53c3\u6578\uff1a\u8981\u66ff\u63db\u7684\u5b57\u4e32\u3001\u66ff\u63db\u5f8c\u7684\u5b57\u4e32\u3001\u4ee5\u53ca\u8981\u66ff\u63db\u7684\u5b57\u4e32\u7684\u9577\u5ea6\u3002<\/p>\n<p>\u8209\u500b\u4f8b\u5b50\uff0c\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u5b57\u4e32 <code>'Hello World'<\/code>\uff0c\u6211\u5011\u60f3\u8981\u5c07\u5b83\u66ff\u63db\u70ba <code>'Goodbye World'<\/code>\uff0c\u90a3\u9ebc\u6211\u5011\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u7684\u7a0b\u5f0f\u78bc\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet str = 'Hello World';\nlet newStr = React.replace(str, 'Goodbye World', 5);\nconsole.log(newStr); \/\/ Goodbye World\n<\/pre>\n<p>\u5728\u9019\u500b\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u9996\u5148\u5b9a\u7fa9\u4e86\u4e00\u500b\u5b57\u4e32 <code>'Hello World'<\/code>\uff0c\u7136\u5f8c\u4f7f\u7528 <code>React.replace()<\/code> \u51fd\u5f0f\u5c07\u5b83\u66ff\u63db\u70ba <code>'Goodbye World'<\/code>\uff0c\u6700\u5f8c\u5c07\u66ff\u63db\u5f8c\u7684\u5b57\u4e32\u8f38\u51fa\u5230\u63a7\u5236\u53f0\u3002<\/p>\n<p>\u9664\u4e86\u53ef\u4ee5\u66ff\u63db\u5b57\u4e32\uff0cReact.JS \u9084\u63d0\u4f9b\u4e86\u4e00\u500b\u53eb\u505a <code>React.split()<\/code> \u7684\u51fd\u5f0f\uff0c\u53ef\u4ee5\u7528\u4f86\u5c07\u5b57\u4e32\u5206\u5272\u6210\u591a\u500b\u5b50\u5b57\u4e32\u3002\u5b83\u63a5\u53d7\u5169\u500b\u53c3\u6578\uff1a\u8981\u5206\u5272\u7684\u5b57\u4e32\u548c\u5206\u5272\u7684\u6a19\u8a18\u3002\u8209\u500b\u4f8b\u5b50\uff0c\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u5b57\u4e32 <code>'Hello World'<\/code>\uff0c\u6211\u5011\u60f3\u8981\u5c07\u5b83\u5206\u5272\u6210 <code>'Hello'<\/code> \u548c <code>'World'<\/code> \u5169\u500b\u5b50\u5b57\u4e32\uff0c\u90a3\u9ebc\u6211\u5011\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u7684\u7a0b\u5f0f\u78bc\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet str = 'Hello World';\nlet newStr = React.split(str, ' ');\nconsole.log(newStr); \/\/ ['Hello', 'World']\n<\/pre>\n<p>\u5728\u9019\u500b\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u9996\u5148\u5b9a\u7fa9\u4e86\u4e00\u500b\u5b57\u4e32 <code>'Hello World'<\/code>\uff0c\u7136\u5f8c\u4f7f\u7528 <code>React.split()<\/code> \u51fd\u5f0f\u5c07\u5b83\u5206\u5272\u6210 <code>'Hello'<\/code> \u548c <code>'World'<\/code> \u5169\u500b\u5b50\u5b57\u4e32\uff0c\u6700\u5f8c\u5c07\u5206\u5272\u5f8c\u7684\u5b57\u4e32\u8f38\u51fa\u5230\u63a7\u5236\u53f0\u3002<\/p>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0cReact.JS \u63d0\u4f9b\u4e86\u4e00\u500b\u53eb\u505a <code>React.replace()<\/code> \u7684\u51fd\u5f0f\uff0c\u53ef\u4ee5\u7528\u4f86\u66ff\u63db\u5b57\u4e32\u4e2d\u7684\u6587\u5b57\uff0c\u4ee5\u53ca\u4e00\u500b\u53eb\u505a <code>React.split()<\/code> \u7684\u51fd\u5f0f\uff0c\u53ef\u4ee5\u7528\u4f86\u5c07\u5b57\u4e32\u5206\u5272\u6210\u591a\u500b\u5b50\u5b57\u4e32\u3002\u9019\u5169\u500b\u51fd\u5f0f\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u8f15\u9b06\u5730\u64cd\u4f5c\u5b57\u4e32\uff0c\u63d0\u9ad8\u958b\u767c\u6548\u7387\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u4ecb\u7d39\u4e86\u5982\u4f55\u4f7f\u7528 React.JS \u4f86\u66ff\u63db\u5b57\u4e32\u3002React.JS \u63d0\u4f9b\u4e86\u4e00\u500b\u53eb\u505a <code>React.replace()<\/code> \u7684\u51fd\u5f0f\uff0c\u53ef\u4ee5\u7528\u4f86\u66ff\u63db\u5b57\u4e32\u4e2d\u7684\u6587\u5b57\uff0c\u4ee5\u53ca\u4e00\u500b\u53eb\u505a <code>React.split()<\/code> \u7684\u51fd\u5f0f\uff0c\u53ef\u4ee5\u7528\u4f86\u5c07\u5b57\u4e32\u5206\u5272\u6210\u591a\u500b\u5b50\u5b57\u4e32\u3002\u9019\u5169\u500b\u51fd\u5f0f\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u8f15\u9b06\u5730\u64cd\u4f5c\u5b57\u4e32\uff0c\u63d0\u9ad8\u958b\u767c\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2.\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528React.JS\u4f86\u66ff\u63db\u5b57\u4e32\uff0c\u4e26\u8a73\u7d30\u89e3\u91cb\u66ff\u63db\u5b57\u4e32\u7684\u65b9\u6cd5\uff0c\u8b93\u5b78\u751f\u80fd\u5920\u66f4\u8f15\u9b06\u5730\u4f7f\u7528React.JS\u4f86\u66ff\u63db\u5b57\u4e32\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-5573","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-1rT","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5573","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=5573"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5573\/revisions"}],"predecessor-version":[{"id":5574,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5573\/revisions\/5574"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}