{"id":27533,"date":"2024-11-24T16:15:36","date_gmt":"2024-11-24T08:15:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27533\/"},"modified":"2024-11-24T16:15:36","modified_gmt":"2024-11-24T08:15:36","slug":"%e9%98%b2%e6%8a%96%e4%bb%a3%e7%a0%81%e7%89%88%e6%9c%ac-1-%e5%92%8c%e7%89%88%e6%9c%ac-2-%e6%89%a7%e8%a1%8c%e7%bb%93%e6%9e%9c%e4%b8%8d%e5%90%8c%e7%9a%84%e5%8e%9f%e5%9b%a0%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27533\/","title":{"rendered":"\u9632\u6296\u4ee3\u7801\u7248\u672c 1 \u548c\u7248\u672c 2 \u6267\u884c\u7ed3\u679c\u4e0d\u540c\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173128664952264.jpg\" class=\"aligncenter\" title=\"\u9632\u6296\u4ee3\u7801\u7248\u672c 1 \u548c\u7248\u672c 2 \u6267\u884c\u7ed3\u679c\u4e0d\u540c\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" alt=\"\u9632\u6296\u4ee3\u7801\u7248\u672c 1 \u548c\u7248\u672c 2 \u6267\u884c\u7ed3\u679c\u4e0d\u540c\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u9632\u6296\u4ee3\u7801\u7684\u4e0d\u540c\u7ed3\u679c\u5256\u6790<\/strong><\/p>\n<p>\u5728\u63d0\u4f9b\u7684\u4e00\u6bb5\u9632\u6296\u4ee3\u7801\u4e2d\uff0c\u5f00\u53d1\u8005\u53d1\u73b0\u7248\u672c 1 \u548c\u7248\u672c 2 \u6267\u884c\u7ed3\u679c\u4e0d\u540c\uff0c\u7248\u672c 1 \u9632\u6296\u5931\u8d25\u3002<\/p>\n<p><strong>\u95ee\u9898\u6839\u6e90\uff1a\u9012\u5f52<\/strong><\/p>\n<p>\u5173\u952e\u70b9\u5728\u4e8e\u9012\u5f52\u3002\u7248\u672c 1 \u4e2d\uff0cif (notCalled &amp;\u200b\u200b&amp; immediate) result = func.apply(context, args); \u8bed\u53e5\u4f4d\u4e8e\u9012\u5f52\u8c03\u7528\u4e4b\u524d\uff0c\u800c\u7248\u672c 2 \u5219\u4f4d\u4e8e\u4e4b\u540e\u3002<\/p>\n<p>\u5728\u7248\u672c 1 \u4e2d\uff0c\u5f53\u6ee1\u8db3\u7acb\u5373\u6267\u884c\u6761\u4ef6\u65f6\uff0c\u6267\u884c\u4e86 func.apply() \u5e76\u9012\u5f52\u8c03\u7528\u81ea\u8eab\u3002\u95ee\u9898\u51fa\u5728 func.apply() \u662f\u540c\u6b65\u6267\u884c\u7684\uff0c\u5b83\u6267\u884c\u4e86\u9012\u5f52\u8c03\u7528\u3002\u7531\u4e8e\u9012\u5f52\u8c03\u7528\u4ecd\u5728\u7ee7\u7eed\uff0cnotCalled \u6761\u4ef6\u59cb\u7ec8\u4e3a\u771f\uff0c\u5bfc\u81f4 func.apply() \u88ab\u91cd\u590d\u6267\u884c\uff0c\u8fd9\u7834\u574f\u4e86\u9632\u6296\u529f\u80fd\u3002<\/p>\n<p>\u800c\u5728\u7248\u672c 2 \u4e2d\uff0cif (notCalled &amp;\u200b\u200b&amp; immediate) result = func.apply(context, args); \u8bed\u53e5\u4f4d\u4e8e\u9012\u5f52\u8c03\u7528\u4e4b\u540e\u3002\u8fd9\u610f\u5473\u7740\u5728\u6761\u4ef6\u6ee1\u8db3\u4e14\u7acb\u5373\u6267\u884c\u65f6\uff0c\u4f1a\u6267\u884c func.apply()\uff0c\u5e76\u8bbe\u7f6e\u8d85\u65f6\u8fdb\u884c\u9012\u5f52\u8c03\u7528\u3002\u6b64\u65f6\uff0cnotCalled \u6761\u4ef6\u4e3a\u5047\uff0c\u9632\u6b62 func.apply() \u88ab\u91cd\u590d\u6267\u884c\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u6b63\u786e\u7684\u9632\u6296\u529f\u80fd\u3002<\/p>\n<p><strong>\u4fee\u6b63\u7248\u672c\uff1a<\/strong><\/p>\n<p>\u5c06\u7248\u672c 1 \u4fee\u6539\u4e3a\u4e0e\u7248\u672c 2 \u4e00\u81f4\uff0c\u5c06 if (notCalled &amp;\u200b\u200b&amp; immediate) result = func.apply(context, args); \u8bed\u53e5\u79fb\u52a8\u5230\u9012\u5f52\u8c03\u7528\u4e4b\u540e\u5373\u53ef\u89e3\u51b3\u95ee\u9898\uff1a<\/p>\n<pre>function debounce(func, wait, immediate) {\n  var timeout\n\n  var debounced = function () {\n    var context = this;\n    var args = arguments;\n    var notCalled = !timeout;\n\n    if (timeout) clearTimeout(timeout);\n    if (!immediate) func.apply(context, args);\n\n    timeout = setTimeout(function () {\n      if (immediate &amp;&amp; notCalled) result = func.apply(context, args);\n      timeout = null;\n    }, wait);\n\n  };\n\n\n  return debounced;\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u9632\u6296\u4ee3\u7801\u7248\u672c 1 \u548c\u7248\u672c 2 \u6267\u884c\u7ed3\u679c\u4e0d\u540c\u7684\u539f\u56e0\u662f\u4ec0\u4e48\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>\u9632\u6296\u4ee3\u7801\u7684\u4e0d\u540c\u7ed3\u679c\u5256\u6790 \u5728\u63d0\u4f9b\u7684\u4e00\u6bb5\u9632\u6296\u4ee3\u7801\u4e2d\uff0c\u5f00\u53d1\u8005\u53d1\u73b0\u7248\u672c 1 \u548c\u7248\u672c 2 \u6267\u884c\u7ed3\u679c\u4e0d\u540c\uff0c\u7248\u672c 1 \u9632\u6296\u5931\u8d25\u3002 \u95ee\u9898\u6839\u6e90\uff1a\u9012\u5f52 \u5173\u952e\u70b9\u5728\u4e8e\u9012\u5f52\u3002\u7248\u672c 1 \u4e2d\uff0cif (notCalled &amp;\u200b\u200b&amp; immediate) result = func.apply(context, args); \u8bed\u53e5\u4f4d\u4e8e\u9012\u5f52\u8c03\u7528\u4e4b\u524d\uff0c\u800c\u7248\u672c 2 \u5219\u4f4d\u4e8e\u4e4b\u540e\u3002 \u5728\u7248\u672c 1 \u4e2d\uff0c\u5f53\u6ee1\u8db3\u7acb\u5373\u6267\u884c\u6761\u4ef6\u65f6\uff0c\u6267\u884c\u4e86 func.apply() \u5e76\u9012\u5f52\u8c03\u7528\u81ea\u8eab\u3002\u95ee\u9898\u51fa\u5728 func.apply() \u662f\u540c\u6b65\u6267\u884c\u7684\uff0c\u5b83\u6267\u884c\u4e86\u9012\u5f52\u8c03\u7528\u3002\u7531\u4e8e\u9012\u5f52\u8c03\u7528\u4ecd\u5728\u7ee7\u7eed\uff0cnotCalled \u6761\u4ef6\u59cb\u7ec8\u4e3a\u771f\uff0c\u5bfc\u81f4 func.apply() \u88ab\u91cd\u590d\u6267\u884c\uff0c\u8fd9\u7834\u574f\u4e86\u9632\u6296\u529f\u80fd\u3002 \u800c\u5728\u7248\u672c 2 \u4e2d\uff0cif (notCalled &amp;\u200b\u200b&amp; immediate) result = func.apply(context, args); \u8bed\u53e5\u4f4d\u4e8e\u9012\u5f52\u8c03\u7528\u4e4b\u540e\u3002\u8fd9\u610f\u5473\u7740\u5728\u6761\u4ef6\u6ee1\u8db3\u4e14\u7acb\u5373\u6267\u884c\u65f6\uff0c\u4f1a\u6267\u884c func.apply()\uff0c\u5e76\u8bbe\u7f6e\u8d85\u65f6\u8fdb\u884c\u9012\u5f52\u8c03\u7528\u3002\u6b64\u65f6\uff0cnotCalled \u6761\u4ef6\u4e3a\u5047\uff0c\u9632\u6b62 func.apply() \u88ab\u91cd\u590d\u6267\u884c\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u6b63\u786e\u7684\u9632\u6296\u529f\u80fd\u3002 \u4fee\u6b63\u7248\u672c\uff1a \u5c06\u7248\u672c 1 \u4fee\u6539\u4e3a\u4e0e\u7248\u672c 2 \u4e00\u81f4\uff0c\u5c06 if (notCalled [&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-27533","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27533","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=27533"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27533\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}