{"id":53521,"date":"2024-12-03T11:26:16","date_gmt":"2024-12-03T03:26:16","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53521\/"},"modified":"2024-12-03T11:26:16","modified_gmt":"2024-12-03T03:26:16","slug":"antd-%e8%a1%a8%e6%a0%bc%e5%86%85%e5%ae%b9%e6%ba%a2%e5%87%ba%e6%97%b6%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e6%bb%9a%e5%8a%a8%e6%98%be%e7%a4%ba%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53521\/","title":{"rendered":"Antd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Antd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\uff1f<\/h1>\n<p>\u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300aAntd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241201\/1733040043674c17abc1470.jpg\" class=\"aligncenter\" title=\"Antd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\uff1f\u63d2\u56fe\" alt=\"Antd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 antd \u5b9e\u73b0\u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u53ef\u6eda\u52a8<\/strong><\/p>\n<p>\u5f53 antd \u4e2d\u7684\u8868\u683c\u6570\u636e\u8fc7\u591a\u5bfc\u81f4\u5185\u5bb9\u6ea2\u51fa\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 card \u548c table \u7ec4\u4ef6\u8054\u5408\u5b9e\u73b0\u5f53\u5185\u5bb9\u65e0\u6cd5\u5b8c\u5168\u5c55\u793a\u65f6\u6eda\u52a8\u663e\u793a\u7684\u6548\u679c\u3002<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>import react from 'react';\nimport { card, table } from 'antd';\n\nconst columns = [\n  \/\/ \u5b9a\u4e49\u8868\u683c\u5217\n];\n\nconst data = [\n  \/\/ \u63d0\u4f9b\u8868\u683c\u6570\u636e\u6e90\n];\n\nconst scrollabletable = () =&gt; {\n  return (\n    &lt;card style={{ height: '400px', overflow: 'auto' }}&gt;\n      &lt;table\n        columns={columns}\n        datasource={data}\n        pagination={{ pagesize: 50 }}\n        scroll={{ y: 300 }}\n      \/&gt;\n    &lt;\/card&gt;\n  );\n};<\/pre>\n<p>\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\uff1a<\/p>\n<ul>\n<li>card \u7ec4\u4ef6\u5305\u88f9 table \u7ec4\u4ef6\uff0c\u8bbe\u7f6e height \u548c overflow \u5c5e\u6027\uff0c\u63a7\u5236\u9ad8\u5ea6\u548c\u5f53\u5185\u5bb9\u6ea2\u51fa\u65f6\u7684\u6eda\u52a8\u3002<\/li>\n<li>table \u7ec4\u4ef6\u7684 pagination \u5c5e\u6027\u8bbe\u7f6e\u6bcf\u9875\u663e\u793a\u7684\u884c\u6570\uff0cscroll \u5c5e\u6027\u8bbe\u7f6e\u8868\u683c\u7684\u6eda\u52a8\u9ad8\u5ea6\u3002<\/li>\n<\/ul>\n<p><strong>\u6837\u5f0f\u8c03\u6574\uff1a<\/strong><\/p>\n<p>\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u4e00\u6b65\u8c03\u6574\u6837\u5f0f\u4ee5\u9002\u5e94\u5177\u4f53\u9700\u6c42\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>card \u7ec4\u4ef6\u7684\u9ad8\u5ea6\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8c03\u6574\uff0c\u9ed8\u8ba4\u4e3a 400px\u3002<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528 css flex \u5e03\u5c40\u8ba9 card \u7ec4\u4ef6\u6839\u636e\u7236\u5bb9\u5668\u7684\u9ad8\u5ea6\u81ea\u9002\u5e94\u3002<\/li>\n<\/ul>\n<p><strong>\u81ea\u9002\u5e94\u9ad8\u5ea6\uff1a<\/strong><\/p>\n<p>\u8981\u8ba9 card \u7ec4\u4ef6\u6839\u636e\u5176\u7236\u5bb9\u5668\u7684\u9ad8\u5ea6\u81ea\u9002\u5e94\uff0c\u800c\u4e0d\u662f\u56fa\u5b9a\u9ad8\u5ea6\uff0c\u4f7f\u7528 css \u7684 flex \u5e03\u5c40\uff1a<\/p>\n<pre>#card-container {\n  height: 100%;\n  display: flex;\n}\n\n#card {\n  height: 100%;\n  display: flex;\n  flex: 1;\n}\n````\n<\/pre>\n<p>\u6587\u4e2d\u5173\u4e8e\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300aAntd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\uff1f\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u8054\u60f3\u7b14\u8bb0\u672c\u600e\u4e48\u91cd\u88c5Win11\u7cfb\u7edf \u5feb\u901f\u91cd\u88c5\u8054\u60f3\u7b14\u8bb0\u672c\u7cfb\u7edf\u7684\u65b9\u6cd5\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Antd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\uff1f \u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300aAntd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01 \u5982\u4f55\u4f7f\u7528 antd \u5b9e\u73b0\u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u53ef\u6eda\u52a8 \u5f53 antd \u4e2d\u7684\u8868\u683c\u6570\u636e\u8fc7\u591a\u5bfc\u81f4\u5185\u5bb9\u6ea2\u51fa\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 card \u548c table \u7ec4\u4ef6\u8054\u5408\u5b9e\u73b0\u5f53\u5185\u5bb9\u65e0\u6cd5\u5b8c\u5168\u5c55\u793a\u65f6\u6eda\u52a8\u663e\u793a\u7684\u6548\u679c\u3002 \u793a\u4f8b\u4ee3\u7801\uff1a import react from &#8216;react&#8217;; import { card, table } from &#8216;antd&#8217;; const columns = [ \/\/ \u5b9a\u4e49\u8868\u683c\u5217 ]; const data = [ \/\/ \u63d0\u4f9b\u8868\u683c\u6570\u636e\u6e90 ]; const scrollabletable = () =&gt; { return ( &lt;card style={{ height: &#8216;400px&#8217;, overflow: &#8216;auto&#8217; }}&gt; [&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-53521","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53521","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=53521"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53521\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}