{"id":28361,"date":"2024-11-24T14:58:55","date_gmt":"2024-11-24T06:58:55","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28361\/"},"modified":"2024-11-24T14:58:55","modified_gmt":"2024-11-24T06:58:55","slug":"%e5%a6%82%e4%bd%95%e6%89%be%e5%88%b0%e8%a1%a8%e6%a0%bc%e5%8d%95%e5%85%83%e6%a0%bc%e5%af%b9%e5%ba%94%e6%96%b9%e5%90%91%e4%b8%8a%e7%9a%84%e5%90%88%e5%b9%b6%e5%8d%95%e5%85%83%e6%a0%bc%e5%9d%90%e6%a0%87","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28361\/","title":{"rendered":"\u5982\u4f55\u627e\u5230\u8868\u683c\u5355\u5143\u683c\u5bf9\u5e94\u65b9\u5411\u4e0a\u7684\u5408\u5e76\u5355\u5143\u683c\u5750\u6807\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173156891780102.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u627e\u5230\u8868\u683c\u5355\u5143\u683c\u5bf9\u5e94\u65b9\u5411\u4e0a\u7684\u5408\u5e76\u5355\u5143\u683c\u5750\u6807\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u627e\u5230\u8868\u683c\u5355\u5143\u683c\u5bf9\u5e94\u65b9\u5411\u4e0a\u7684\u5408\u5e76\u5355\u5143\u683c\u5750\u6807\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>table \u5355\u5143\u683c\u5982\u4f55\u627e\u5230\u5bf9\u5e94\u65b9\u5411\u4e0a\u7684\u5408\u5e76\u5355\u5143\u683c\u5750\u6807<\/strong><\/p>\n<p>\u9762\u5bf9 table \u5355\u5143\u683c\u4e2d\u5b58\u5728\u5408\u5e76\u7684\u573a\u666f\uff0c\u6211\u4eec\u9700\u8981\u627e\u5230\u5bf9\u5e94\u7684\u5408\u5e76\u5355\u5143\u683c\u5750\u6807\u4ee5\u8fdb\u884c\u5408\u5e76\u64cd\u4f5c\u3002\u5e38\u89c1\u7684\u5408\u5e76\u65b9\u5411\u5305\u62ec\u5411\u4e0a\u3001\u4e0b\u3001\u5de6\u3001\u53f3\u3002\u4ee5\u5411\u4e0a\u5408\u5e76\u4e3a\u4f8b\uff0c\u539f\u601d\u8def\u662f\u627e\u5230\u4e0a\u4e00\u4e2a\u5355\u5143\u683c\u5e76\u589e\u52a0\u5176 rowspan \u5c5e\u6027\uff0c\u540c\u65f6\u5220\u9664\u5f53\u524d\u5355\u5143\u683c\u3002<\/p>\n<p>\u90a3\u4e48\u5982\u4f55\u627e\u5230\u4e0a\u4e00\u4e2a\u5355\u5143\u683c\u5462\uff1f<\/p>\n<p><strong>\u601d\u8def\u4e00\uff1a\u8c03\u6574\u5750\u6807\u89c4\u5219<\/strong><\/p>\n<p>\u539f\u59cb\u5750\u6807\u89c4\u5219\u4f7f\u7528\u5408\u5e76\u7684\u5355\u5143\u683c\u4f5c\u4e3a\u57fa\u51c6\uff0c\u5982 [2,0] \u8868\u793a\u5408\u5e76\u4e86\u4e24\u4e2a\u5355\u5143\u683c\u540e\u7684\u4e00\u4e2a\u5355\u5143\u683c\u3002\u5efa\u8bae\u4fee\u6539\u5750\u6807\u89c4\u5219\uff0c\u4ee5 1&#215;1 \u5355\u5143\u683c\u4e3a\u57fa\u51c6\uff0c\u5c06 [2,0] \u8c03\u6574\u4e3a [2,1]\u3002<\/p>\n<p>\u6839\u636e\u4fee\u6539\u540e\u7684\u5750\u6807\u89c4\u5219\uff0c\u5411\u4e0a\u67e5\u627e\u53ea\u9700\u8981\u9012\u51cf\u884c\u5750\u6807\u5373\u53ef\u3002<\/p>\n<p><strong>\u4ee3\u7801\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>findNearCell(tableData, 2, 1, 'top'); \/\/ \u8fd4\u56de {row:0, col:1}\n\n\/\/ \u67e5\u627e\u5411\u4e0b\u5408\u5e76\u7684\u5355\u5143\u683c\nfunction findNearCell(tableData, row, col, direction) {\n  let tempRow = row;\n  let tempCol = col;\n\n  switch (direction) {\n    case 'top':\n      while (tableData[tempRow] &amp;&amp; tempRow &gt;= 0 &amp;&amp; tableData[tempRow][tempCol] &amp;&amp; tableData[tempRow][tempCol].rowspan &gt; 1) {\n        tempRow--;\n      }\n      if (tableData[tempRow] &amp;&amp; tableData[tempRow][tempCol]) {\n        return { row: tempRow, col: tempCol };\n      }\n      break;\n  }\n\n  return null;\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u627e\u5230\u8868\u683c\u5355\u5143\u683c\u5bf9\u5e94\u65b9\u5411\u4e0a\u7684\u5408\u5e76\u5355\u5143\u683c\u5750\u6807\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>table \u5355\u5143\u683c\u5982\u4f55\u627e\u5230\u5bf9\u5e94\u65b9\u5411\u4e0a\u7684\u5408\u5e76\u5355\u5143\u683c\u5750\u6807 \u9762\u5bf9 table \u5355\u5143\u683c\u4e2d\u5b58\u5728\u5408\u5e76\u7684\u573a\u666f\uff0c\u6211\u4eec\u9700\u8981\u627e\u5230\u5bf9\u5e94\u7684\u5408\u5e76\u5355\u5143\u683c\u5750\u6807\u4ee5\u8fdb\u884c\u5408\u5e76\u64cd\u4f5c\u3002\u5e38\u89c1\u7684\u5408\u5e76\u65b9\u5411\u5305\u62ec\u5411\u4e0a\u3001\u4e0b\u3001\u5de6\u3001\u53f3\u3002\u4ee5\u5411\u4e0a\u5408\u5e76\u4e3a\u4f8b\uff0c\u539f\u601d\u8def\u662f\u627e\u5230\u4e0a\u4e00\u4e2a\u5355\u5143\u683c\u5e76\u589e\u52a0\u5176 rowspan \u5c5e\u6027\uff0c\u540c\u65f6\u5220\u9664\u5f53\u524d\u5355\u5143\u683c\u3002 \u90a3\u4e48\u5982\u4f55\u627e\u5230\u4e0a\u4e00\u4e2a\u5355\u5143\u683c\u5462\uff1f \u601d\u8def\u4e00\uff1a\u8c03\u6574\u5750\u6807\u89c4\u5219 \u539f\u59cb\u5750\u6807\u89c4\u5219\u4f7f\u7528\u5408\u5e76\u7684\u5355\u5143\u683c\u4f5c\u4e3a\u57fa\u51c6\uff0c\u5982 [2,0] \u8868\u793a\u5408\u5e76\u4e86\u4e24\u4e2a\u5355\u5143\u683c\u540e\u7684\u4e00\u4e2a\u5355\u5143\u683c\u3002\u5efa\u8bae\u4fee\u6539\u5750\u6807\u89c4\u5219\uff0c\u4ee5 1&#215;1 \u5355\u5143\u683c\u4e3a\u57fa\u51c6\uff0c\u5c06 [2,0] \u8c03\u6574\u4e3a [2,1]\u3002 \u6839\u636e\u4fee\u6539\u540e\u7684\u5750\u6807\u89c4\u5219\uff0c\u5411\u4e0a\u67e5\u627e\u53ea\u9700\u8981\u9012\u51cf\u884c\u5750\u6807\u5373\u53ef\u3002 \u4ee3\u7801\u793a\u4f8b\uff1a findNearCell(tableData, 2, 1, &#8216;top&#8217;); \/\/ \u8fd4\u56de {row:0, col:1} \/\/ \u67e5\u627e\u5411\u4e0b\u5408\u5e76\u7684\u5355\u5143\u683c function findNearCell(tableData, row, col, direction) { let tempRow = row; let tempCol = col; switch (direction) { case &#8216;top&#8217;: while (tableData[tempRow] &amp;&amp; tempRow &gt;= 0 &amp;&amp; [&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-28361","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28361","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=28361"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28361\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}