{"id":5623,"date":"2023-01-06T10:55:01","date_gmt":"2023-01-06T02:55:01","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5623"},"modified":"2023-01-06T10:55:01","modified_gmt":"2023-01-06T02:55:01","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8react-js%e5%88%a4%e6%96%b7%e7%a9%ba%e5%ad%97%e7%ac%a6%e4%b8%b2isemptystring","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/react-js\/%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8react-js%e5%88%a4%e6%96%b7%e7%a9%ba%e5%ad%97%e7%ac%a6%e4%b8%b2isemptystring\/","title":{"rendered":"\u5b78\u7fd2\u5982\u4f55\u5229\u7528React.JS\u5224\u65b7\u7a7a\u5b57\u7b26\u4e32(isEmptyString)"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"React.JS, isEmptyString\"><\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 React.JS \u5224\u65b7\u5b57\u4e32\u662f\u5426\u70ba\u7a7a\u5b57\u7b26\u4e32(isEmptyString)<\/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 JavaScript \u4f86\u5224\u65b7\u5b57\u4e32\u662f\u5426\u70ba\u7a7a\u5b57\u7b26\u4e32\uff0c\u9019\u5c0d\u65bc\u69cb\u5efa\u9ad8\u6027\u80fd\u7684\u61c9\u7528\u7a0b\u5e8f\u4f86\u8aaa\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002<\/p>\n<h2>\u4f7f\u7528 React.JS \u5224\u65b7\u5b57\u4e32\u662f\u5426\u70ba\u7a7a\u5b57\u7b26\u4e32<\/h2>\n<p>\u5728 React.JS \u4e2d\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528 JavaScript \u4f86\u5224\u65b7\u5b57\u4e32\u662f\u5426\u70ba\u7a7a\u5b57\u7b26\u4e32\u3002\u6700\u7c21\u55ae\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 JavaScript \u7684 <code>String.prototype.length<\/code> \u5c6c\u6027\uff0c\u5b83\u53ef\u4ee5\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u9577\u5ea6\uff0c\u5982\u679c\u5b57\u7b26\u4e32\u7684\u9577\u5ea6\u70ba 0\uff0c\u5247\u8868\u793a\u8a72\u5b57\u7b26\u4e32\u70ba\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<pre class=\"brush: javascript\">\nfunction isEmptyString(str) {\n  return str.length === 0;\n}\n<\/pre>\n<p>\u53e6\u4e00\u7a2e\u65b9\u6cd5\u662f\u4f7f\u7528 JavaScript \u7684 <code>String.prototype.trim()<\/code> \u65b9\u6cd5\uff0c\u5b83\u53ef\u4ee5\u5c07\u5b57\u7b26\u4e32\u4e2d\u7684\u7a7a\u683c\u548c\u63db\u884c\u7b26\u53bb\u9664\uff0c\u5982\u679c\u5b57\u7b26\u4e32\u7684\u9577\u5ea6\u70ba 0\uff0c\u5247\u8868\u793a\u8a72\u5b57\u7b26\u4e32\u70ba\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<pre class=\"brush: javascript\">\nfunction isEmptyString(str) {\n  return str.trim().length === 0;\n}\n<\/pre>\n<p>\u6b64\u5916\uff0c\u958b\u767c\u8005\u9084\u53ef\u4ee5\u4f7f\u7528 JavaScript \u7684 <code>String.prototype.match()<\/code> \u65b9\u6cd5\uff0c\u5b83\u53ef\u4ee5\u6aa2\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u7b26\u5408\u6307\u5b9a\u7684\u6b63\u5247\u8868\u9054\u5f0f\uff0c\u5982\u679c\u5b57\u7b26\u4e32\u4e0d\u7b26\u5408\u6307\u5b9a\u7684\u6b63\u5247\u8868\u9054\u5f0f\uff0c\u5247\u8868\u793a\u8a72\u5b57\u7b26\u4e32\u70ba\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<pre class=\"brush: javascript\">\nfunction isEmptyString(str) {\n  return !str.match(\/\\S\/);\n}\n<\/pre>\n<h2>\u7e3d\u7d50<\/h2>\n<p>\u5728 React.JS \u4e2d\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528 JavaScript \u4f86\u5224\u65b7\u5b57\u4e32\u662f\u5426\u70ba\u7a7a\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>String.prototype.length<\/code>\u3001<code>String.prototype.trim()<\/code> \u548c <code>String.prototype.match()<\/code> \u4e09\u7a2e\u65b9\u6cd5\u4f86\u5224\u65b7\u5b57\u7b26\u4e32\u662f\u5426\u70ba\u7a7a\u5b57\u7b26\u4e32\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u4f7f\u7528\u9019\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u8f15\u9b06\u5730\u69cb\u5efa\u9ad8\u6027\u80fd\u7684\u7db2\u9801\u61c9\u7528\u7a0b\u5e8f\uff0c\u4e26\u78ba\u4fdd\u61c9\u7528\u7a0b\u5e8f\u7684\u53ef\u9760\u6027\u548c\u53ef\u7528\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5229\u7528React.JS\u4f86\u5224\u65b7\u5b57\u4e32\u662f\u5426\u70ba\u7a7a\u5b57\u7b26\u4e32\uff0c\u4e26\u63d0\u4f9b\u7c21\u55ae\u7684\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0c\u8b93\u5b78\u751f\u80fd\u5920\u5feb\u901f\u4e0a\u624b\uff0c\u5b78\u7fd2\u5982\u4f55\u5229\u7528React.JS\u4f86\u5224\u65b7\u7a7a\u5b57\u7b26\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-5623","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-1sH","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5623","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=5623"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5623\/revisions"}],"predecessor-version":[{"id":5624,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5623\/revisions\/5624"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}