{"id":28308,"date":"2024-11-24T10:09:49","date_gmt":"2024-11-24T02:09:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28308\/"},"modified":"2024-11-24T10:09:49","modified_gmt":"2024-11-24T02:09:49","slug":"%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87%e4%bf%ae%e6%94%b9%e5%8d%95%e5%85%83%e6%a0%bc%e5%9d%90%e6%a0%87%e8%a7%84%e5%88%99%e6%9f%a5%e6%89%be-table-%e5%8d%95%e5%85%83%e6%a0%bc%e7%9a%84%e5%90%88%e5%b9%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28308\/","title":{"rendered":"\u5982\u4f55\u901a\u8fc7\u4fee\u6539\u5355\u5143\u683c\u5750\u6807\u89c4\u5219\u67e5\u627e table \u5355\u5143\u683c\u7684\u5408\u5e76\u76ee\u6807\u5750\u6807\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173148858397834.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u901a\u8fc7\u4fee\u6539\u5355\u5143\u683c\u5750\u6807\u89c4\u5219\u67e5\u627e table \u5355\u5143\u683c\u7684\u5408\u5e76\u76ee\u6807\u5750\u6807\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u901a\u8fc7\u4fee\u6539\u5355\u5143\u683c\u5750\u6807\u89c4\u5219\u67e5\u627e table \u5355\u5143\u683c\u7684\u5408\u5e76\u76ee\u6807\u5750\u6807\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5bfb\u627e table \u5355\u5143\u683c\u52a8\u6001\u5408\u5e76\u76ee\u6807\u5750\u6807<\/strong><\/p>\n<p>\u5728 table \u5408\u5e76\u64cd\u4f5c\u4e2d\uff0c\u786e\u5b9a\u5408\u5e76\u76ee\u6807\u5355\u5143\u683c\u7684\u5750\u6807\u81f3\u5173\u91cd\u8981\u3002\u672c\u6587\u63d0\u51fa\u4e86\u4e00\u79cd\u6709\u6548\u7684\u65b9\u6cd5\u6765\u67e5\u627e\u7279\u5b9a\u65b9\u5411\u4e0a\u7684\u76ee\u6807\u5355\u5143\u683c\u5750\u6807\u3002<\/p>\n<p>\u4ee5\u5355\u5143\u683c [2, 0] \u4e3a\u4f8b\uff0c\u5411\u4e0a\u5408\u5e76\u7684\u601d\u8def\u662f\u5c06 [0, 1] \u5355\u5143\u683c\u7684 rowspan++ \u5e76\u5220\u9664 [2, 0] \u5355\u5143\u683c\u3002\u7136\u800c\uff0c\u76f4\u63a5\u5bfb\u627e [0, 1] \u5355\u5143\u683c\u5b58\u5728\u56f0\u96be\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\u662f\u4fee\u6539\u5355\u5143\u683c\u5750\u6807\u89c4\u5219\u3002\u4ee5 1&#215;1 \u5355\u5143\u683c\u4e3a\u57fa\u672c\u5355\u4f4d\uff0c\u5c06 [2, 0] \u8c03\u6574\u4e3a [2, 1]\u3002\u8fd9\u6837\uff0c\u5411\u4e0a\u67e5\u627e\u76ee\u6807\u5355\u5143\u683c\u65f6\uff0c\u53ea\u9700\u8981\u9012\u51cf\u884c\u5750\u6807\u5373\u53ef\u3002<\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u4ee3\u7801\u5b9e\u73b0\u4e86\u8fd9\u4e00\u601d\u8def\uff1a<\/p>\n<pre>function findNearCell(tableData, row, col, direction) {\n  if (direction === 'top') {\n    row--;\n  } else if (direction === 'bottom') {\n    row++;\n  } else if (direction === 'left') {\n    col--;\n  } else if (direction === 'right') {\n    col++;\n  }\n\n  return { row, col };\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8c03\u7528 findNearCell \u51fd\u6570\u5373\u53ef\u83b7\u5f97\u5408\u5e76\u76ee\u6807\u5355\u5143\u683c\u7684\u5750\u6807\uff1a<\/p>\n<pre>const targetCell = findNearCell(tableData, 2, 0, 'top');\nconsole.log(targetCell); \/\/ { row: 0, col: 1 }<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u901a\u8fc7\u4fee\u6539\u5355\u5143\u683c\u5750\u6807\u89c4\u5219\u67e5\u627e table \u5355\u5143\u683c\u7684\u5408\u5e76\u76ee\u6807\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>\u5bfb\u627e table \u5355\u5143\u683c\u52a8\u6001\u5408\u5e76\u76ee\u6807\u5750\u6807 \u5728 table \u5408\u5e76\u64cd\u4f5c\u4e2d\uff0c\u786e\u5b9a\u5408\u5e76\u76ee\u6807\u5355\u5143\u683c\u7684\u5750\u6807\u81f3\u5173\u91cd\u8981\u3002\u672c\u6587\u63d0\u51fa\u4e86\u4e00\u79cd\u6709\u6548\u7684\u65b9\u6cd5\u6765\u67e5\u627e\u7279\u5b9a\u65b9\u5411\u4e0a\u7684\u76ee\u6807\u5355\u5143\u683c\u5750\u6807\u3002 \u4ee5\u5355\u5143\u683c [2, 0] \u4e3a\u4f8b\uff0c\u5411\u4e0a\u5408\u5e76\u7684\u601d\u8def\u662f\u5c06 [0, 1] \u5355\u5143\u683c\u7684 rowspan++ \u5e76\u5220\u9664 [2, 0] \u5355\u5143\u683c\u3002\u7136\u800c\uff0c\u76f4\u63a5\u5bfb\u627e [0, 1] \u5355\u5143\u683c\u5b58\u5728\u56f0\u96be\u3002 \u89e3\u51b3\u65b9\u6848\u662f\u4fee\u6539\u5355\u5143\u683c\u5750\u6807\u89c4\u5219\u3002\u4ee5 1&#215;1 \u5355\u5143\u683c\u4e3a\u57fa\u672c\u5355\u4f4d\uff0c\u5c06 [2, 0] \u8c03\u6574\u4e3a [2, 1]\u3002\u8fd9\u6837\uff0c\u5411\u4e0a\u67e5\u627e\u76ee\u6807\u5355\u5143\u683c\u65f6\uff0c\u53ea\u9700\u8981\u9012\u51cf\u884c\u5750\u6807\u5373\u53ef\u3002 \u4ee5\u4e0b\u793a\u4f8b\u4ee3\u7801\u5b9e\u73b0\u4e86\u8fd9\u4e00\u601d\u8def\uff1a function findNearCell(tableData, row, col, direction) { if (direction === &#8216;top&#8217;) { row&#8211;; } else if (direction === &#8216;bottom&#8217;) { row++; } else if (direction === [&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-28308","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28308","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=28308"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28308\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}