{"id":52305,"date":"2024-12-03T16:06:23","date_gmt":"2024-12-03T08:06:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52305\/"},"modified":"2024-12-03T16:06:23","modified_gmt":"2024-12-03T08:06:23","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e7%9c%81%e5%b8%82%e5%8c%ba%e6%a0%91%e7%bb%93%e6%9e%84%e6%89%81%e5%b9%b3%e5%8c%96%e5%b9%b6%e5%9b%9e%e6%98%be%e9%80%89%e4%b8%ad%e7%8a%b6%e6%80%81%ef%bc%9f-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52305\/","title":{"rendered":"\u5982\u4f55\u5c06\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u5e76\u56de\u663e\u9009\u4e2d\u72b6\u6001\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u5c06\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u5e76\u56de\u663e\u9009\u4e2d\u72b6\u6001\uff1f <\/h1>\n<p>\u4eca\u5929\u7c73\u4e91\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u5c06\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u5e76\u56de\u663e\u9009\u4e2d\u72b6\u6001\uff1f \u300b<\/span>\uff0c\u5176\u4e2d\u6d89\u53ca\u5230\u7684\u77e5\u8bc6\u70b9\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u65e0\u8bba\u4f60\u662f\u5c0f\u767d\u8fd8\u662f\u8001\u624b\uff0c\u90fd\u9002\u5408\u770b\u4e00\u770b\u54e6~\u6709\u597d\u7684\u5efa\u8bae\u4e5f\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u82e5\u662f\u770b\u5b8c\u6709\u6240\u6536\u83b7\uff0c\u4e5f\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u70b9\u8d5e\u652f\u6301\u5440\uff01\u4e00\u8d77\u52a0\u6cb9\u5b66\u4e60~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241119\/1732026096673c9ef0a392e.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5c06\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u5e76\u56de\u663e\u9009\u4e2d\u72b6\u6001\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5c06\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u5e76\u56de\u663e\u9009\u4e2d\u72b6\u6001\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u7ed3\u6784\u4e2d\u56de\u663e\u7701\u5e02\u533a\u9009\u4e2d\u72b6\u6001<\/strong><\/p>\n<p>\u5728\u7701\u5e02\u533a\u6811\u5f62\u7ed3\u6784\u4e2d\uff0c\u53ea\u6709\u5f53\u524d\u5c42\u7ea7\u7684\u8282\u70b9\u62e5\u6709\u9009\u4e2d\u6807\u5fd7\uff0c\u5176\u4ed6\u5c42\u7ea7\u7684\u8282\u70b9\u7684\u9009\u4e2d\u6807\u5fd7\u90fd\u4e3a\u7a7a\u3002\u73b0\u5728\u9700\u8981\u5c06\u9009\u4e2d\u7684\u7701\u5e02\u533a\u7684\u4ee3\u7801\u5217\u8868\u5c55\u5e73\u6210\u4e00\u4e2a\u6570\u7ec4\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528\u9012\u5f52\u7b97\u6cd5\u4ece\u6839\u8282\u70b9\u5f00\u59cb\u904d\u5386\u6574\u4e2a\u6811\u5f62\u7ed3\u6784\uff0c\u5e76\u4f20\u9012\u5f53\u524d\u7236\u8282\u70b9\u7684\u9009\u4e2d\u72b6\u6001\u3002<\/p>\n<p><strong>\u5177\u4f53\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\u4e3a\u6bcf\u4e2a\u8282\u70b9\u5224\u65ad\u662f\u5426\u9009\u4e2d\u3002\u5982\u679c\u5f53\u524d\u8282\u70b9\u9009\u4e2d\u6216\u5176\u7236\u8282\u70b9\u9009\u4e2d\uff0c\u5219\u8ba4\u4e3a\u8be5\u8282\u70b9\u53ca\u5176\u6240\u6709\u5b50\u8282\u70b9\u90fd\u9009\u4e2d\u3002<\/li>\n<li>\u904d\u5386\u8282\u70b9\u7684\u5b50\u8282\u70b9\uff0c\u5e76\u5c06\u5176\u7236\u8282\u70b9\u7684\u9009\u4e2d\u72b6\u6001\u4f20\u9012\u7ed9\u5b83\u4eec\u3002<\/li>\n<li>\u5982\u679c\u8282\u70b9\u4e0d\u5305\u542b\u5b50\u8282\u70b9\uff0c\u5219\u5c06\u5176\u4ee3\u7801\u6dfb\u52a0\u5230\u9009\u4e2d\u7684\u4ee3\u7801\u5217\u8868\u4e2d\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>\/**\n * \u83b7\u53d6\u6240\u6709\u9009\u4e2d\u7684\u4ee3\u7801\n * @param {any[]} list \u6811\u5f62\u7ed3\u6784\n * @param {string[]} parentList \u5230\u7236\u7ea7\u6240\u6709\u7684\u4ee3\u7801\u7684\u6570\u7ec4\n * @param {boolean} parentChecked \u4e0a\u7ea7\u662f\u5426\u88ab\u9009\u4e2d\uff0c\u82e5\u4e0a\u7ea7\u88ab\u9009\u4e2d\uff0c\u5219\u4e0b\u9762\u6240\u6709\u7684\u5b50\u9009\u9879\u5747\u662f\u88ab\u9009\u4e2d\u7684\u6570\u636e\n *\/\nconst getCheckedList = (list, parentList = [], parentChecked = false) =&gt; {\n  let result = [];\n\n  if (!Array.isArray(list)) {\n    return result;\n  }\n\n  list.forEach((item) =&gt; {\n    const checked = parentChecked || item.check; \/\/ \u7236\u7ea7\u88ab\u9009\u4e2d\u6216\u5f53\u524d\u88ab\u9009\u4e2d\uff0c\u5747\u8ba4\u4e3a\u662f\u88ab\u9009\u4e2d\n    const codeList = parentList.concat(item.code);\n\n    if (item.children) {\n      \/\/ \u5f53\u524d\u4e0d\u662f\u6700\u5185\u5c42\n      result = result.concat(getCheckedList(item.children, codeList, checked));\n    } else {\n      \/\/ \u5df2\u5230\u6700\u5185\u5c42\n      if (checked) {\n        result.push(codeList);\n      }\n    }\n  });\n\n  return result;\n};\n\nconst tree = ...; \/\/ \u5728\u8fd9\u91cc\u586b\u5145\u4f60\u7684\u6811\u5f62\u7ed3\u6784\nconst checkedList = getCheckedList(tree);<\/pre>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300a\u5982\u4f55\u5c06\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u5e76\u56de\u663e\u9009\u4e2d\u72b6\u6001\uff1f \u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   win10\u5b89\u88c5\u5931\u8d25\u63d0\u793a\u5904\u7406\u5668\u4e0d\u652f\u6301NX\u600e\u4e48\u529e\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5c06\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u5e76\u56de\u663e\u9009\u4e2d\u72b6\u6001\uff1f \u4eca\u5929\u7c73\u4e91\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86\u300a\u5982\u4f55\u5c06\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u5e76\u56de\u663e\u9009\u4e2d\u72b6\u6001\uff1f \u300b\uff0c\u5176\u4e2d\u6d89\u53ca\u5230\u7684\u77e5\u8bc6\u70b9\u5305\u62ec\u7b49\u7b49\uff0c\u65e0\u8bba\u4f60\u662f\u5c0f\u767d\u8fd8\u662f\u8001\u624b\uff0c\u90fd\u9002\u5408\u770b\u4e00\u770b\u54e6~\u6709\u597d\u7684\u5efa\u8bae\u4e5f\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u82e5\u662f\u770b\u5b8c\u6709\u6240\u6536\u83b7\uff0c\u4e5f\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u70b9\u8d5e\u652f\u6301\u5440\uff01\u4e00\u8d77\u52a0\u6cb9\u5b66\u4e60~ \u5728\u7701\u5e02\u533a\u6811\u7ed3\u6784\u6241\u5e73\u5316\u7ed3\u6784\u4e2d\u56de\u663e\u7701\u5e02\u533a\u9009\u4e2d\u72b6\u6001 \u5728\u7701\u5e02\u533a\u6811\u5f62\u7ed3\u6784\u4e2d\uff0c\u53ea\u6709\u5f53\u524d\u5c42\u7ea7\u7684\u8282\u70b9\u62e5\u6709\u9009\u4e2d\u6807\u5fd7\uff0c\u5176\u4ed6\u5c42\u7ea7\u7684\u8282\u70b9\u7684\u9009\u4e2d\u6807\u5fd7\u90fd\u4e3a\u7a7a\u3002\u73b0\u5728\u9700\u8981\u5c06\u9009\u4e2d\u7684\u7701\u5e02\u533a\u7684\u4ee3\u7801\u5217\u8868\u5c55\u5e73\u6210\u4e00\u4e2a\u6570\u7ec4\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u4f7f\u7528\u9012\u5f52\u7b97\u6cd5\u4ece\u6839\u8282\u70b9\u5f00\u59cb\u904d\u5386\u6574\u4e2a\u6811\u5f62\u7ed3\u6784\uff0c\u5e76\u4f20\u9012\u5f53\u524d\u7236\u8282\u70b9\u7684\u9009\u4e2d\u72b6\u6001\u3002 \u5177\u4f53\u6b65\u9aa4\uff1a \u4e3a\u6bcf\u4e2a\u8282\u70b9\u5224\u65ad\u662f\u5426\u9009\u4e2d\u3002\u5982\u679c\u5f53\u524d\u8282\u70b9\u9009\u4e2d\u6216\u5176\u7236\u8282\u70b9\u9009\u4e2d\uff0c\u5219\u8ba4\u4e3a\u8be5\u8282\u70b9\u53ca\u5176\u6240\u6709\u5b50\u8282\u70b9\u90fd\u9009\u4e2d\u3002 \u904d\u5386\u8282\u70b9\u7684\u5b50\u8282\u70b9\uff0c\u5e76\u5c06\u5176\u7236\u8282\u70b9\u7684\u9009\u4e2d\u72b6\u6001\u4f20\u9012\u7ed9\u5b83\u4eec\u3002 \u5982\u679c\u8282\u70b9\u4e0d\u5305\u542b\u5b50\u8282\u70b9\uff0c\u5219\u5c06\u5176\u4ee3\u7801\u6dfb\u52a0\u5230\u9009\u4e2d\u7684\u4ee3\u7801\u5217\u8868\u4e2d\u3002 \u793a\u4f8b\u4ee3\u7801\uff1a \/** * \u83b7\u53d6\u6240\u6709\u9009\u4e2d\u7684\u4ee3\u7801 * @param {any[]} list \u6811\u5f62\u7ed3\u6784 * @param {string[]} parentList \u5230\u7236\u7ea7\u6240\u6709\u7684\u4ee3\u7801\u7684\u6570\u7ec4 * @param {boolean} parentChecked \u4e0a\u7ea7\u662f\u5426\u88ab\u9009\u4e2d\uff0c\u82e5\u4e0a\u7ea7\u88ab\u9009\u4e2d\uff0c\u5219\u4e0b\u9762\u6240\u6709\u7684\u5b50\u9009\u9879\u5747\u662f\u88ab\u9009\u4e2d\u7684\u6570\u636e *\/ const getCheckedList = (list, parentList = [], parentChecked = false) =&gt; { let result = []; if (!Array.isArray(list)) { return result; } list.forEach((item) =&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-52305","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52305","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=52305"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52305\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}