{"id":5729,"date":"2023-01-06T14:48:54","date_gmt":"2023-01-06T06:48:54","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5729"},"modified":"2023-01-06T14:48:54","modified_gmt":"2023-01-06T06:48:54","slug":"%e4%bd%bf%e7%94%a8react-js%e6%b1%82%e5%8f%96%e5%9b%9b%e5%88%86%e4%bd%8d%e6%95%b8","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/react-js\/%e4%bd%bf%e7%94%a8react-js%e6%b1%82%e5%8f%96%e5%9b%9b%e5%88%86%e4%bd%8d%e6%95%b8\/","title":{"rendered":"\u4f7f\u7528React.JS\u6c42\u53d6\u56db\u5206\u4f4d\u6578"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"React, React List, Quartiles\"><\/p>\n<h1>\u4f7f\u7528 React.JS \u6c42\u56db\u5206\u4f4d\u6578(quartiles)<\/h1>\n<p>React.JS \u662f\u4e00\u500b\u7528\u65bc\u69cb\u5efa\u7528\u6236\u7aef\u61c9\u7528\u7a0b\u5e8f\u7684 JavaScript \u5eab\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5feb\u901f\u69cb\u5efa\u51fa\u9ad8\u6027\u80fd\u7684\u7db2\u9801\u61c9\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528 React.JS \u4f86\u6c42\u53d6\u56db\u5206\u4f4d\u6578(quartiles)\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f\u56db\u5206\u4f4d\u6578(quartiles)<\/h2>\n<p>\u56db\u5206\u4f4d\u6578(quartiles)\u662f\u4e00\u7a2e\u7d71\u8a08\u5b78\u4e2d\u7684\u6982\u5ff5\uff0c\u5b83\u6307\u7684\u662f\u4e00\u7d44\u6578\u64da\u4e2d\u7684\u56db\u500b\u5206\u4f4d\u6578\uff0c\u5206\u5225\u662f\u6700\u5c0f\u503c\u3001\u7b2c\u4e00\u56db\u5206\u4f4d\u6578\u3001\u4e2d\u4f4d\u6578\u548c\u7b2c\u4e09\u56db\u5206\u4f4d\u6578\u3002\u5b83\u53ef\u4ee5\u7528\u4f86\u63cf\u8ff0\u4e00\u7d44\u6578\u64da\u7684\u5206\u4f4d\u60c5\u6cc1\uff0c\u4ee5\u53ca\u6578\u64da\u7684\u5206\u4f4d\u60c5\u6cc1\u8207\u5176\u4ed6\u6578\u64da\u7684\u6bd4\u8f03\u3002<\/p>\n<h2>\u5982\u4f55\u4f7f\u7528 React.JS \u6c42\u53d6\u56db\u5206\u4f4d\u6578(quartiles)<\/h2>\n<p>\u4f7f\u7528 React.JS \u6c42\u53d6\u56db\u5206\u4f4d\u6578(quartiles)\u7684\u65b9\u6cd5\u975e\u5e38\u7c21\u55ae\uff0c\u53ea\u9700\u8981\u4f7f\u7528 React List \u7d44\u4ef6\u4f86\u69cb\u5efa\u4e00\u500b\u6578\u64da\u5217\u8868\uff0c\u7136\u5f8c\u4f7f\u7528 JavaScript \u7684 sort() \u65b9\u6cd5\u5c0d\u6578\u64da\u9032\u884c\u6392\u5e8f\uff0c\u6700\u5f8c\u4f7f\u7528 Math.floor() \u65b9\u6cd5\u5c31\u53ef\u4ee5\u6c42\u53d6\u56db\u5206\u4f4d\u6578(quartiles)\u4e86\u3002<\/p>\n<pre class=\"brush: javascript\">\nimport React from 'react';\nimport ReactList from 'react-list';\n\nconst data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\nconst quartiles = data.sort((a, b) => a - b).map(num => Math.floor(num \/ 4));\n\nconst MyList = () => (\n  <ReactList\n    itemRenderer={(index, key) => <div key={key}>{quartiles[index]}<\/div>}\n    length={quartiles.length}\n    type='uniform'\n  \/>\n);\n\nexport default MyList;\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u9996\u5148\u4f7f\u7528 React List \u7d44\u4ef6\u4f86\u69cb\u5efa\u4e00\u500b\u6578\u64da\u5217\u8868\uff0c\u7136\u5f8c\u4f7f\u7528 JavaScript \u7684 sort() \u65b9\u6cd5\u5c0d\u6578\u64da\u9032\u884c\u6392\u5e8f\uff0c\u6700\u5f8c\u4f7f\u7528 Math.floor() \u65b9\u6cd5\u5c31\u53ef\u4ee5\u6c42\u53d6\u56db\u5206\u4f4d\u6578(quartiles)\u4e86\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u7d50\u8ad6<\/h2>\n<p>\u4f7f\u7528 React.JS \u4f86\u6c42\u53d6\u56db\u5206\u4f4d\u6578(quartiles)\u662f\u4e00\u500b\u975e\u5e38\u7c21\u55ae\u7684\u4efb\u52d9\uff0c\u53ea\u9700\u8981\u4f7f\u7528 React List \u7d44\u4ef6\u4f86\u69cb\u5efa\u4e00\u500b\u6578\u64da\u5217\u8868\uff0c\u7136\u5f8c\u4f7f\u7528 JavaScript \u7684 sort() \u65b9\u6cd5\u5c0d\u6578\u64da\u9032\u884c\u6392\u5e8f\uff0c\u6700\u5f8c\u4f7f\u7528 Math.floor() \u65b9\u6cd5\u5c31\u53ef\u4ee5\u6c42\u53d6\u56db\u5206\u4f4d\u6578(quartiles)\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1a\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528React.JS\u6c42\u53d6\u56db\u5206\u4f4d\u6578\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u7c21\u55ae\u7684\u7bc4\u4f8b\u4f86\u89e3\u91cb\u5982\u4f55\u4f7f\u7528React.JS\u4f86\u8a08\u7b97\u56db\u5206\u4f4d\u6578\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-5729","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-1up","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5729","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=5729"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5729\/revisions"}],"predecessor-version":[{"id":5730,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5729\/revisions\/5730"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}