{"id":26152,"date":"2024-11-24T12:05:55","date_gmt":"2024-11-24T04:05:55","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26152\/"},"modified":"2024-11-24T12:05:55","modified_gmt":"2024-11-24T04:05:55","slug":"%e5%9c%a8react%e4%b8%ad%ef%bc%8c%e5%a6%82%e4%bd%95%e5%af%b9ant-design%e7%bb%84%e4%bb%b6%e7%9a%84%e5%a4%9a%e4%b8%aaclass%e8%bf%9b%e8%a1%8c%e6%a0%b7%e5%bc%8f%e4%bf%ae%e6%94%b9%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26152\/","title":{"rendered":"\u5728React\u4e2d\uff0c\u5982\u4f55\u5bf9Ant Design\u7ec4\u4ef6\u7684\u591a\u4e2aclass\u8fdb\u884c\u6837\u5f0f\u4fee\u6539\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173081676187758.jpg\" class=\"aligncenter\" title=\"\u5728React\u4e2d\uff0c\u5982\u4f55\u5bf9Ant Design\u7ec4\u4ef6\u7684\u591a\u4e2aclass\u8fdb\u884c\u6837\u5f0f\u4fee\u6539\uff1f\u63d2\u56fe\" alt=\"\u5728React\u4e2d\uff0c\u5982\u4f55\u5bf9Ant Design\u7ec4\u4ef6\u7684\u591a\u4e2aclass\u8fdb\u884c\u6837\u5f0f\u4fee\u6539\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5bf9 ant design \u7ec4\u4ef6\u7684\u591a\u4e2a class \u8fdb\u884c\u6837\u5f0f\u4fee\u6539<\/strong><\/p>\n<p>\u5728 react \u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6a21\u5757\u5316  \u6765\u4fee\u6539 ant design \u7ec4\u4ef6\u7684\u6837\u5f0f\u3002\u7136\u800c\uff0c\u5982\u679c\u60a8\u9700\u8981\u5bf9\u540c\u4e00\u5143\u7d20\u5e94\u7528\u591a\u4e2a\u6837\u5f0f\u7c7b\uff0c\u9ed8\u8ba4\u7684\u591a classname \u8986\u76d6\u5c06\u4e0d\u8d77\u4f5c\u7528\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e24\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528\u53e0\u52a0\u7c7b<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 css \u7c7b\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u73b0\u6709\u7684\u7c7b\u540d\u4e2d\uff0c\u4ee5\u4fbf\u53e0\u52a0\u66f4\u6539\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>.my-custom-collapse:global(.ant-collapse) {\n  border-radius: 0px !important; \/* \u53bb\u9664\u9876\u90e8\u548c\u5de6\u8fb9\u7684\u5706\u89d2 *\/\n  .ant-collapse-header:last-child { \/* \u53bb\u9664\u6700\u540e\u4e00\u4e2a item \u4e0b\u8fb9\u7684\u5706\u89d2 *\/\n    border-radius: 0px !important;\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7136\u540e\u5728\u60a8\u7684\u7ec4\u4ef6\u4e2d\u4f7f\u7528\u65b0\u7684\u81ea\u5b9a\u4e49\u7c7b\uff1a<\/p>\n<pre>import styles from '.\/index.module.css'\n\n...\n\n&lt;collapse classname={styles.my-custom-collapse} ... \/&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u4f7f\u7528\u9009\u62e9\u5668\u5d4c\u5957<\/strong><\/p>\n<p>\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528 css \u9009\u62e9\u5668\u5d4c\u5957\u6765\u5b9e\u73b0\u66f4\u5177\u4f53\u7684\u76ee\u6807\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>.my-collapse:global(.ant-collapse) {\n  border-radius: 0px !important;\n  \n  &gt; .ant-collapse-item:last-child .ant-collapse-header { \/* \u4ec5\u9488\u5bf9\u6700\u540e\u4e00\u4e2a item \u7684\u6807\u9898\u5e94\u7528\u6837\u5f0f *\/\n    border-radius: 0px !important;\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u9009\u62e9\u5668\u5d4c\u5957\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u4e0d\u9002\u7528\u4e8e ant design \u7ec4\u4ef6\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728React\u4e2d\uff0c\u5982\u4f55\u5bf9Ant Design\u7ec4\u4ef6\u7684\u591a\u4e2aclass\u8fdb\u884c\u6837\u5f0f\u4fee\u6539\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5bf9 ant design \u7ec4\u4ef6\u7684\u591a\u4e2a class \u8fdb\u884c\u6837\u5f0f\u4fee\u6539 \u5728 react \u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6a21\u5757\u5316 \u6765\u4fee\u6539 ant design \u7ec4\u4ef6\u7684\u6837\u5f0f\u3002\u7136\u800c\uff0c\u5982\u679c\u60a8\u9700\u8981\u5bf9\u540c\u4e00\u5143\u7d20\u5e94\u7528\u591a\u4e2a\u6837\u5f0f\u7c7b\uff0c\u9ed8\u8ba4\u7684\u591a classname \u8986\u76d6\u5c06\u4e0d\u8d77\u4f5c\u7528\u3002 \u89e3\u51b3\u65b9\u6848 \u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e24\u79cd\u65b9\u6cd5\uff1a 1. \u4f7f\u7528\u53e0\u52a0\u7c7b \u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 css \u7c7b\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u73b0\u6709\u7684\u7c7b\u540d\u4e2d\uff0c\u4ee5\u4fbf\u53e0\u52a0\u66f4\u6539\u3002\u4f8b\u5982\uff1a .my-custom-collapse:global(.ant-collapse) { border-radius: 0px !important; \/* \u53bb\u9664\u9876\u90e8\u548c\u5de6\u8fb9\u7684\u5706\u89d2 *\/ .ant-collapse-header:last-child { \/* \u53bb\u9664\u6700\u540e\u4e00\u4e2a item \u4e0b\u8fb9\u7684\u5706\u89d2 *\/ border-radius: 0px !important; } } \u767b\u5f55\u540e\u590d\u5236 \u7136\u540e\u5728\u60a8\u7684\u7ec4\u4ef6\u4e2d\u4f7f\u7528\u65b0\u7684\u81ea\u5b9a\u4e49\u7c7b\uff1a import styles from &#8216;.\/index.module.css&#8217; &#8230; &lt;collapse classname={styles.my-custom-collapse} &#8230; \/&gt; \u767b\u5f55\u540e\u590d\u5236 2. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-26152","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=26152"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26152\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}