{"id":28244,"date":"2024-11-24T13:09:09","date_gmt":"2024-11-24T05:09:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28244\/"},"modified":"2024-11-24T13:09:09","modified_gmt":"2024-11-24T05:09:09","slug":"el-table-%e5%90%88%e5%b9%b6%e9%83%a8%e5%88%86%e6%88%90%e5%8a%9f%e9%83%a8%e5%88%86%e5%a4%b1%e8%b4%a5%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28244\/","title":{"rendered":"El-table \u5408\u5e76\u90e8\u5206\u6210\u529f\u90e8\u5206\u5931\u8d25\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173147023157952.jpg\" class=\"aligncenter\" title=\"El-table \u5408\u5e76\u90e8\u5206\u6210\u529f\u90e8\u5206\u5931\u8d25\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"El-table \u5408\u5e76\u90e8\u5206\u6210\u529f\u90e8\u5206\u5931\u8d25\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>el-table\u5408\u5e76\u90e8\u5206\u6210\u529f\u90e8\u5206\u4e0d\u6210\u529f<\/strong><\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/p>\n<p>\u5728\u6e32\u67d3el-table\u65f6\uff0c\u9700\u8981\u5c06\u524d\u56db\u5217\u6570\u636e\u5408\u5e76\uff0c\u4f46\u51fa\u73b0\u4e86\u90e8\u5206\u5408\u5e76\u6210\u529f\uff0c\u90e8\u5206\u4e0d\u6210\u529f\u7684\u60c5\u51b5\u3002<\/p>\n<p><strong>\u95ee\u9898\u4ee3\u7801<\/strong><\/p>\n<pre>&lt;el-table :data=\"waterData\" border :span-method=\"handleSpanM\"&gt;\n  ...\n&lt;\/el-table&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    <\/p>\n<pre>export default {\n  methods: {\n    handleSpanM({ row, column, rowIndex, columnIndex }) {\n      if (columnIndex === 0) {\n        return { rowspan: row.length }\n      }\n    },\n  },\n};<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u95ee\u9898\u539f\u56e0<\/strong><\/p>\n<p>handleSpanM\u65b9\u6cd5\u4e2d\uff0c\u5408\u5e76\u7b2c\u4e00\u5217\u65f6\u4f7f\u7528\u4e86\u56fa\u5b9a\u7684rowspan\uff0c\u6ca1\u6709\u8003\u8651\u4e0d\u540c\u7684\u6570\u636e\u884c\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u6839\u636e\u5b9e\u9645\u6570\u636e\u884c\u6570\u52a8\u6001\u8ba1\u7b97rowspan\uff1a<\/p>\n<pre>export default {\n  methods: {\n    handleSpanM({ row, column, rowIndex, columnIndex }) {\n      if (columnIndex === 0) {\n        \/\/ \u83b7\u53d6\u5f53\u524d\u884c\u4e0e\u4e0b\u4e00\u884cname\u76f8\u540c\u7684\u884c\u6570\n        let count = 1;\n        for (let i = rowIndex + 1; i &lt; row.length; i++) {\n          if (row[i].name === row[rowIndex].name) {\n            count++;\n          } else {\n            break;\n          }\n        }\n        return { rowspan: count }\n      }\n    },\n  },\n};<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u8865\u5145\uff1a\u8868\u683c\u4e0d\u53ef\u7f16\u8f91\u8bbe\u5b9a<\/strong><\/p>\n<p><strong>\u524d\u56db\u5217\u4e0d\u53ef\u7f16\u8f91<\/strong><\/p>\n<p>\u5728el-table-column\u4e2d\u8bbe\u7f6edisabled\u5c5e\u6027\uff1a<\/p>\n<pre>&lt;el-table-column width=\"65\" disabled&gt;...&lt;\/el-table-column&gt;\n&lt;el-table-column width=\"70\" disabled&gt;...&lt;\/el-table-column&gt;\n&lt;el-table-column width=\"120\" disabled&gt;...&lt;\/el-table-column&gt;\n&lt;el-table-column width=\"180\" disabled&gt;...&lt;\/el-table-column&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u540e\u51e0\u5217\u8868\u5934\u4e0d\u53ef\u7f16\u8f91<\/strong><\/p>\n<p>\u5728el-input\u4e2d\u8bbe\u7f6edisabled\u5c5e\u6027\uff1a<\/p>\n<pre>&lt;el-input disabled size=\"small\" v-model=\"waterForm[`water${index + 1}_label`]\" &gt;&lt;\/el-input&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fEl-table \u5408\u5e76\u90e8\u5206\u6210\u529f\u90e8\u5206\u5931\u8d25\uff0c\u5982\u4f55\u89e3\u51b3\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>el-table\u5408\u5e76\u90e8\u5206\u6210\u529f\u90e8\u5206\u4e0d\u6210\u529f \u95ee\u9898\u63cf\u8ff0 \u5728\u6e32\u67d3el-table\u65f6\uff0c\u9700\u8981\u5c06\u524d\u56db\u5217\u6570\u636e\u5408\u5e76\uff0c\u4f46\u51fa\u73b0\u4e86\u90e8\u5206\u5408\u5e76\u6210\u529f\uff0c\u90e8\u5206\u4e0d\u6210\u529f\u7684\u60c5\u51b5\u3002 \u95ee\u9898\u4ee3\u7801 &lt;el-table :data=&#8221;waterData&#8221; border :span-method=&#8221;handleSpanM&#8221;&gt; &#8230; &lt;\/el-table&gt; \u767b\u5f55\u540e\u590d\u5236 export default { methods: { handleSpanM({ row, column, rowIndex, columnIndex }) { if (columnIndex === 0) { return { rowspan: row.length } } }, }, }; \u767b\u5f55\u540e\u590d\u5236 \u95ee\u9898\u539f\u56e0 handleSpanM\u65b9\u6cd5\u4e2d\uff0c\u5408\u5e76\u7b2c\u4e00\u5217\u65f6\u4f7f\u7528\u4e86\u56fa\u5b9a\u7684rowspan\uff0c\u6ca1\u6709\u8003\u8651\u4e0d\u540c\u7684\u6570\u636e\u884c\u3002 \u89e3\u51b3\u65b9\u6848 \u6839\u636e\u5b9e\u9645\u6570\u636e\u884c\u6570\u52a8\u6001\u8ba1\u7b97rowspan\uff1a export default { methods: { handleSpanM({ row, column, rowIndex, columnIndex }) { if [&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-28244","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28244","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=28244"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28244\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}