{"id":5577,"date":"2023-01-06T09:45:04","date_gmt":"2023-01-06T01:45:04","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5577"},"modified":"2023-01-06T09:45:04","modified_gmt":"2023-01-06T01:45:04","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8react-js%e5%8e%bb%e9%99%a4%e5%ad%97%e4%b8%b2%e9%a6%96%e5%b0%be%e7%a9%ba%e6%a0%bc","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-js%e5%8e%bb%e9%99%a4%e5%ad%97%e4%b8%b2%e9%a6%96%e5%b0%be%e7%a9%ba%e6%a0%bc\/","title":{"rendered":"\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528React.JS\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7a7a\u683c"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"React.JS, trim\"><\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 React.JS \u5b57\u4e32\u7684\u9996\u5c3e\u7a7a\u683c\u53bb\u9664(trim)<\/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\u66f4\u8f15\u9b06\u5730\u69cb\u5efa\u9ad8\u6027\u80fd\u7684\u7db2\u9801\u61c9\u7528\u7a0b\u5e8f\u3002\u5728 React.JS \u4e2d\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528 trim() \u65b9\u6cd5\u4f86\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u7a7a\u683c\u3002<\/p>\n<h2>trim() \u65b9\u6cd5\u7684\u4f7f\u7528<\/h2>\n<p>trim() \u65b9\u6cd5\u53ef\u4ee5\u7528\u65bc\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u7a7a\u683c\uff0c\u5b83\u53ef\u4ee5\u63a5\u53d7\u4e00\u500b\u53c3\u6578\uff0c\u7528\u65bc\u6307\u5b9a\u8981\u53bb\u9664\u7684\u5b57\u7b26\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u53c3\u6578\uff0c\u5247\u9ed8\u8a8d\u53bb\u9664\u7a7a\u683c\u3002<\/p>\n<pre class=\"brush: javascript\">\n\/\/ \u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u7a7a\u683c\nlet str = '  Hello World  ';\nlet newStr = str.trim();\nconsole.log(newStr); \/\/ 'Hello World'\n\n\/\/ \u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u6307\u5b9a\u5b57\u7b26\nlet str = '**Hello World**';\nlet newStr = str.trim('*');\nconsole.log(newStr); \/\/ 'Hello World'\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 trim() \u65b9\u6cd5\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u7a7a\u683c\uff0c\u4e5f\u53ef\u4ee5\u6307\u5b9a\u8981\u53bb\u9664\u7684\u5b57\u7b26\uff0c\u4f8b\u5982\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u5011\u6307\u5b9a\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684 * \u5b57\u7b26\u3002<\/p>\n<h2>trimStart() \u548c trimEnd() \u65b9\u6cd5\u7684\u4f7f\u7528<\/h2>\n<p>React.JS \u4e5f\u63d0\u4f9b\u4e86 trimStart() \u548c trimEnd() \u65b9\u6cd5\uff0c\u5b83\u5011\u53ef\u4ee5\u5206\u5225\u7528\u65bc\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u7a7a\u683c\u6216\u6307\u5b9a\u5b57\u7b26\u3002<\/p>\n<pre class=\"brush: javascript\">\n\/\/ \u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u7a7a\u683c\nlet str = '  Hello World  ';\nlet newStr = str.trimStart();\nconsole.log(newStr); \/\/ 'Hello World  '\n\n\/\/ \u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u6307\u5b9a\u5b57\u7b26\nlet str = '**Hello World**';\nlet newStr = str.trimEnd('*');\nconsole.log(newStr); \/\/ '**Hello World'\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 trimStart() \u65b9\u6cd5\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u7a7a\u683c\uff0c\u4e5f\u53ef\u4ee5\u6307\u5b9a\u8981\u53bb\u9664\u7684\u5b57\u7b26\uff0c\u4f8b\u5982\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u5011\u6307\u5b9a\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684 * \u5b57\u7b26\u3002<\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>\u5728 React.JS \u4e2d\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528 trim()\u3001trimStart() \u548c trimEnd() \u65b9\u6cd5\u4f86\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7684\u7a7a\u683c\u6216\u6307\u5b9a\u5b57\u7b26\uff0c\u9019\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u8f15\u9b06\u5730\u64cd\u4f5c\u5b57\u4e32\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u66f4\u591a\u5b78\u7fd2\u8cc7\u6e90<\/h2>\n<p>\u5982\u679c\u4f60\u60f3\u8981\u66f4\u591a\u5b78\u7fd2 React.JS \u7684\u8cc7\u6e90\uff0c\u53ef\u4ee5\u53c3\u8003\u4ee5\u4e0b\u7684\u8cc7\u6e90\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/reactjs.org\/\" target=\"_blank\" rel=\"noopener\">React.JS \u5b98\u65b9\u7db2\u7ad9<\/a><\/li>\n<li><a href=\"https:\/\/www.tutorialspoint.com\/reactjs\/\" target=\"_blank\" rel=\"noopener\">React.JS \u6559\u7a0b<\/a><\/li>\n<li><a href=\"https:\/\/www.codecademy.com\/learn\/react-101\" target=\"_blank\" rel=\"noopener\">Codecademy React.JS \u8ab2\u7a0b<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1a\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528React.JS\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7a7a\u683c\uff0c\u672c\u6587\u5c07\u4ecb\u7d39React.JS\u4e2d\u7684trim()\u51fd\u6578\uff0c\u8b93\u4f60\u53ef\u4ee5\u8f15\u9b06\u53bb\u9664\u5b57\u4e32\u9996\u5c3e\u7a7a\u683c\uff0c\u8b93\u4f60\u7684\u7a0b\u5f0f\u66f4\u52a0\u7c21\u6f54\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-5577","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-1rX","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5577","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=5577"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5577\/revisions"}],"predecessor-version":[{"id":5578,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5577\/revisions\/5578"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}