{"id":27592,"date":"2024-11-24T09:35:53","date_gmt":"2024-11-24T01:35:53","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27592\/"},"modified":"2024-11-24T09:35:53","modified_gmt":"2024-11-24T01:35:53","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","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27592\/","title":{"rendered":"Antd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173129439422291.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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\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  \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  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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fAntd \u8868\u683c\u5185\u5bb9\u6ea2\u51fa\u65f6\u5982\u4f55\u5b9e\u73b0\u6eda\u52a8\u663e\u793a\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\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; &lt;table columns={columns} datasource={data} pagination={{ [&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-27592","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27592","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=27592"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27592\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}