{"id":56613,"date":"2025-08-14T20:55:02","date_gmt":"2025-08-14T12:55:02","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/56613.html"},"modified":"2025-08-14T20:55:02","modified_gmt":"2025-08-14T12:55:02","slug":"react-vue-%e6%80%a7%e8%83%bd%e5%b4%a9%e4%ba%86%ef%bc%9fjs-%e9%98%b2%e6%8a%96%e8%8a%82%e6%b5%81%e7%bb%88%e6%9e%81%e6%96%b9%e6%a1%88%ef%bc%8c%e8%ae%a9%e9%a1%b5%e9%9d%a2%e4%b8%9d%e6%bb%91%e5%a6%82","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/56613.html","title":{"rendered":"React\/Vue \u6027\u80fd\u5d29\u4e86\uff1fJS \u9632\u6296\u8282\u6d41\u7ec8\u6781\u65b9\u6848\uff0c\u8ba9\u9875\u9762\u4e1d\u6ed1\u5982\u5fb7\u8299"},"content":{"rendered":"<p>\u5728\u5f53\u4eca\u7684\u524d\u7aef\u5f00\u53d1\u9886\u57df&#xff0c;React \u548c Vue \u65e0\u7591\u662f\u4e24\u9897\u7480\u74a8\u7684\u660e\u661f&#xff0c;\u5b83\u4eec\u4ee5\u5404\u81ea\u72ec\u7279\u7684\u4f18\u52bf&#xff0c;\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u51fa\u4ea4\u4e92\u4e30\u5bcc\u3001\u7528\u6237\u4f53\u9a8c\u51fa\u8272\u7684 Web \u5e94\u7528\u3002\u7136\u800c&#xff0c;\u968f\u7740\u5e94\u7528\u529f\u80fd\u7684\u65e5\u76ca\u590d\u6742\u3001\u6570\u636e\u91cf\u7684\u4e0d\u65ad\u589e\u5927&#xff0c;\u6027\u80fd\u95ee\u9898\u4e5f\u9010\u6e10\u6d6e\u51fa\u6c34\u9762&#xff0c;\u6210\u4e3a\u56f0\u6270\u5f00\u53d1\u8005\u7684\u4e00\u5927\u96be\u9898\u3002\u4f60\u662f\u5426\u9047\u5230\u8fc7\u8fd9\u6837\u7684\u573a\u666f&#xff1a;\u5728 React \u5e94\u7528\u4e2d&#xff0c;\u9891\u7e41\u5730\u5207\u6362\u7ec4\u4ef6\u72b6\u6001&#xff0c;\u9875\u9762\u5374\u51fa\u73b0\u660e\u663e\u7684\u5361\u987f&#xff1b;\u6216\u8005\u5728 Vue \u9879\u76ee\u91cc&#xff0c;\u8fdb\u884c\u5927\u91cf\u6570\u636e\u7684\u5217\u8868\u6e32\u67d3\u65f6&#xff0c;\u6eda\u52a8\u64cd\u4f5c\u53d8\u5f97\u8fdf\u7f13\u4e0d\u6d41\u7545\u3002\u8fd9\u4e9b\u73b0\u8c61\u5f80\u5f80\u610f\u5473\u7740\u5e94\u7528\u7684\u6027\u80fd\u5df2\u7ecf\u4eae\u8d77\u4e86\u7ea2\u706f&#xff0c;\u800c\u5176\u4e2d\u4e00\u4e2a\u91cd\u8981\u7684\u5bfc\u706b\u7d22&#xff0c;\u5c31\u662f\u9891\u7e41\u89e6\u53d1\u7684\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u3002\u8fd9\u65f6\u5019&#xff0c;JS \u7684\u9632\u6296\u8282\u6d41\u6280\u672f\u4fbf\u5982\u540c\u6551\u661f\u4e00\u822c&#xff0c;\u4e3a\u89e3\u51b3\u8fd9\u7c7b\u6027\u80fd\u95ee\u9898\u63d0\u4f9b\u4e86\u6709\u6548\u7684\u65b9\u6848\u3002\u200b<\/p>\n<p>\u7406\u89e3\u6027\u80fd\u74f6\u9888&#xff1a;\u9891\u7e41\u89e6\u53d1\u4e8b\u4ef6\u7684\u5371\u5bb3\u200b<\/p>\n<p>\u5728\u6df1\u5165\u63a2\u8ba8\u9632\u6296\u8282\u6d41\u4e4b\u524d&#xff0c;\u6211\u4eec\u5148\u6765\u5256\u6790\u4e00\u4e0b\u9891\u7e41\u89e6\u53d1\u4e8b\u4ef6\u4e3a\u4f55\u4f1a\u8ba9 React \u548c Vue \u5e94\u7528\u7684\u6027\u80fd\u5927\u6253\u6298\u6263\u3002\u4ee5\u4e00\u4e2a\u5e38\u89c1\u7684\u641c\u7d22\u6846\u4e3a\u4f8b&#xff0c;\u5f53\u7528\u6237\u5728\u8f93\u5165\u5185\u5bb9\u65f6&#xff0c;\u6bcf\u4e00\u6b21\u6309\u952e\u90fd\u4f1a\u89e6\u53d1 keyup \u4e8b\u4ef6\u3002\u5047\u8bbe\u5728\u8fd9\u4e2a\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u4e2d&#xff0c;\u6211\u4eec\u4f1a\u5411\u670d\u52a1\u5668\u53d1\u9001\u641c\u7d22\u8bf7\u6c42&#xff0c;\u83b7\u53d6\u5339\u914d\u7684\u7ed3\u679c\u5e76\u66f4\u65b0\u9875\u9762\u5c55\u793a\u3002\u5982\u679c\u4e0d\u5bf9\u4e8b\u4ef6\u7684\u89e6\u53d1\u9891\u7387\u52a0\u4ee5\u63a7\u5236&#xff0c;\u5728\u7528\u6237\u5feb\u901f\u8f93\u5165\u7684\u8fc7\u7a0b\u4e2d&#xff0c;\u77ed\u65f6\u95f4\u5185\u5c31\u4f1a\u4ea7\u751f\u5927\u91cf\u7684\u8bf7\u6c42\u3002\u8fd9\u4e0d\u4ec5\u4f1a\u7ed9\u670d\u52a1\u5668\u5e26\u6765\u5de8\u5927\u7684\u538b\u529b&#xff0c;\u5bfc\u81f4\u54cd\u5e94\u5ef6\u8fdf&#xff0c;\u8fd8\u4f1a\u4f7f\u5f97\u524d\u7aef\u9891\u7e41\u5730\u66f4\u65b0 DOM\u3002\u5728 React \u548c Vue \u4e2d&#xff0c;\u867d\u7136\u865a\u62df DOM \u673a\u5236\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u4f18\u5316\u4e86 DOM \u66f4\u65b0\u7684\u6027\u80fd&#xff0c;\u4f46\u8fc7\u4e8e\u9891\u7e41\u7684\u66f4\u65b0\u64cd\u4f5c\u4ecd\u7136\u4f1a\u6d88\u8017\u5927\u91cf\u7684\u8d44\u6e90&#xff0c;\u9020\u6210\u9875\u9762\u5361\u987f&#xff0c;\u4e25\u91cd\u5f71\u54cd\u7528\u6237\u4f53\u9a8c\u3002\u540c\u6837&#xff0c;\u5728\u9875\u9762\u6eda\u52a8\u4e8b\u4ef6 scroll \u4e2d&#xff0c;\u5982\u679c\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u4e2d\u6267\u884c\u4e86\u590d\u6742\u7684\u8ba1\u7b97\u6216 DOM \u64cd\u4f5c&#xff0c;\u9891\u7e41\u89e6\u53d1\u4e5f\u4f1a\u4f7f\u4e3b\u7ebf\u7a0b\u5fd9\u4e8e\u5904\u7406\u8fd9\u4e9b\u4efb\u52a1&#xff0c;\u65e0\u6cd5\u53ca\u65f6\u54cd\u5e94\u7528\u6237\u7684\u5176\u4ed6\u4ea4\u4e92\u64cd\u4f5c&#xff0c;\u5bfc\u81f4\u9875\u9762\u5931\u53bb\u6d41\u7545\u6027\u3002\u200b<\/p>\n<p>\u9632\u6296&#xff08;Debounce&#xff09;&#xff1a;\u7cbe\u51c6\u63a7\u5236&#xff0c;\u907f\u514d\u65e0\u6548\u89e6\u53d1\u200b<\/p>\n<p>\u9632\u6296\u7684\u6838\u5fc3\u539f\u7406\u200b<\/p>\n<p>\u9632\u6296\u7684\u6982\u5ff5\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a&#xff1a;\u5f53\u4e00\u4e2a\u4e8b\u4ef6\u88ab\u89e6\u53d1\u540e&#xff0c;\u8bbe\u5b9a\u4e00\u4e2a\u5ef6\u8fdf\u65f6\u95f4 n \u79d2&#xff0c;\u5728\u8fd9 n \u79d2\u5185\u5982\u679c\u8be5\u4e8b\u4ef6\u518d\u6b21\u88ab\u89e6\u53d1&#xff0c;\u5c31\u6e05\u9664\u4e4b\u524d\u7684\u5ef6\u8fdf\u8ba1\u65f6&#xff0c;\u91cd\u65b0\u5f00\u59cb\u8ba1\u65f6\u3002\u53ea\u6709\u5f53 n \u79d2\u5185\u4e8b\u4ef6\u6ca1\u6709\u518d\u6b21\u88ab\u89e6\u53d1\u65f6&#xff0c;\u624d\u4f1a\u771f\u6b63\u6267\u884c\u6211\u4eec\u60f3\u8981\u7684\u51fd\u6570\u64cd\u4f5c\u3002\u53ef\u4ee5\u5c06\u5176\u60f3\u8c61\u6210\u4e00\u4e2a\u9632\u6296\u52a8\u7684\u5f00\u5173&#xff0c;\u5728\u9891\u7e41\u7684\u89e6\u53d1\u64cd\u4f5c\u4e2d&#xff0c;\u5b83\u4e0d\u4f1a\u7acb\u5373\u54cd\u5e94&#xff0c;\u800c\u662f\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u7684\u7a33\u5b9a\u671f&#xff0c;\u786e\u4fdd\u6ca1\u6709\u65b0\u7684\u89e6\u53d1\u540e&#xff0c;\u624d\u6267\u884c\u76f8\u5e94\u7684\u52a8\u4f5c\u3002\u200b<\/p>\n<p>React \u4e2d\u5b9e\u73b0\u9632\u6296\u200b<\/p>\n<p>\u5728 React \u5e94\u7528\u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u94a9\u5b50\u51fd\u6570&#xff08;Custom Hook&#xff09;\u6765\u5b9e\u73b0\u9632\u6296\u529f\u80fd&#xff0c;\u4ee5\u4fbf\u5728\u591a\u4e2a\u7ec4\u4ef6\u4e2d\u590d\u7528\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u9632\u6296\u94a9\u5b50\u51fd\u6570\u7684\u5b9e\u73b0&#xff1a;\u200b<\/p>\n<p>\u200b<\/p>\n<p>TypeScript\u53d6\u6d88\u81ea\u52a8\u6362\u884c\u590d\u5236<\/p>\n<p>import { useCallback, useRef } from&#039;react&#039;;\u200b<\/p>\n<p>\u200b<\/p>\n<p>const useDebounce &#061; (callback, delay) &#061;&gt; {\u200b<\/p>\n<p>const timer &#061; useRef();\u200b<\/p>\n<p>\u200b<\/p>\n<p>return useCallback((&#8230;args) &#061;&gt; {\u200b<\/p>\n<p>if (timer.current) {\u200b<\/p>\n<p>clearTimeout(timer.current);\u200b<\/p>\n<p>}\u200b<\/p>\n<p>timer.current &#061; setTimeout(() &#061;&gt; {\u200b<\/p>\n<p>callback(&#8230;args);\u200b<\/p>\n<p>timer.current &#061; null;\u200b<\/p>\n<p>}, delay);\u200b<\/p>\n<p>}, [callback, delay]);\u200b<\/p>\n<p>};\u200b<\/p>\n<p>\u200b<\/p>\n<p>\u4f7f\u7528\u8fd9\u4e2a\u94a9\u5b50\u51fd\u6570\u4e5f\u975e\u5e38\u7b80\u5355&#xff0c;\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u641c\u7d22\u7ec4\u4ef6&#xff0c;\u9700\u8981\u5728\u7528\u6237\u505c\u6b62\u8f93\u5165 300 \u6beb\u79d2\u540e\u624d\u53d1\u8d77\u641c\u7d22\u8bf7\u6c42&#xff1a;\u200b<\/p>\n<p>\u200b<\/p>\n<p>TypeScript\u53d6\u6d88\u81ea\u52a8\u6362\u884c\u590d\u5236<\/p>\n<p>import React, { useState } from&#039;react&#039;;\u200b<\/p>\n<p>import useDebounce from &#039;.\/useDebounce&#039;;\u200b<\/p>\n<p>\u200b<\/p>\n<p>const SearchComponent &#061; () &#061;&gt; {\u200b<\/p>\n<p>const [searchQuery, setSearchQuery] &#061; useState(&#039;&#039;);\u200b<\/p>\n<p>const handleSearch &#061; useDebounce((query) &#061;&gt; {\u200b<\/p>\n<p>\/\/ \u8fd9\u91cc\u6267\u884c\u5b9e\u9645\u7684\u641c\u7d22\u903b\u8f91&#xff0c;\u4f8b\u5982\u5411\u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\u200b<\/p>\n<p>console.log(&#039;Searching for:&#039;, query);\u200b<\/p>\n<p>}, 300);\u200b<\/p>\n<p>\u200b<\/p>\n<p>const handleInputChange &#061; (e) &#061;&gt; {\u200b<\/p>\n<p>const value &#061; e.target.value;\u200b<\/p>\n<p>setSearchQuery(value);\u200b<\/p>\n<p>handleSearch(value);\u200b<\/p>\n<p>};\u200b<\/p>\n<p>\u200b<\/p>\n<p>return (\u200b<\/p>\n<p>&lt;div&gt;\u200b<\/p>\n<p>&lt;input type&#061;&#034;text&#034; value&#061;{searchQuery} onChange&#061;{handleInputChange} \/&gt;\u200b<\/p>\n<p>\u200b<\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c; useDebounce \u94a9\u5b50\u51fd\u6570\u63a5\u6536\u4e00\u4e2a\u56de\u8c03\u51fd\u6570 callback \u548c\u5ef6\u8fdf\u65f6\u95f4 delay \u4f5c\u4e3a\u53c2\u6570\u3002\u5728 handleInputChange \u51fd\u6570\u4e2d&#xff0c;\u6bcf\u6b21\u8f93\u5165\u6846\u7684\u503c\u53d1\u751f\u53d8\u5316\u65f6&#xff0c;\u90fd\u4f1a\u8c03\u7528 handleSearch &#xff0c;\u4f46\u7531\u4e8e\u9632\u6296\u7684\u4f5c\u7528&#xff0c;\u53ea\u6709\u5728\u7528\u6237\u505c\u6b62\u8f93\u5165 300 \u6beb\u79d2\u540e&#xff0c; handleSearch \u4e2d\u7684\u5b9e\u9645\u641c\u7d22\u903b\u8f91\u624d\u4f1a\u88ab\u6267\u884c\u3002\u200b<\/p>\n<p>Vue \u4e2d\u5b9e\u73b0\u9632\u6296\u200b<\/p>\n<p>\u5728 Vue \u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u6307\u4ee4&#xff08;Directive&#xff09;\u6765\u5b9e\u73b0\u9632\u6296\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u9632\u6296\u6307\u4ee4\u7684\u5b9e\u73b0&#xff1a;\u200b<\/p>\n<p>\u200b<\/p>\n<p>TypeScript\u53d6\u6d88\u81ea\u52a8\u6362\u884c\u590d\u5236<\/p>\n<p>\/\/ \u5728main.js\u4e2d\u5b9a\u4e49\u5168\u5c40\u6307\u4ee4\u200b<\/p>\n<p>Vue.directive(&#039;debounce&#039;, {\u200b<\/p>\n<p>inserted: function (el, binding) {\u200b<\/p>\n<p>let timer;\u200b<\/p>\n<p>el.addEventListener(&#039;click&#039;, function () {\u200b<\/p>\n<p>if (timer) {\u200b<\/p>\n<p>clearTimeout(timer);\u200b<\/p>\n<p>}\u200b<\/p>\n<p>timer &#061; setTimeout(() &#061;&gt; {\u200b<\/p>\n<p>binding.value();\u200b<\/p>\n<p>timer &#061; null;\u200b<\/p>\n<p>}, binding.arg || 300);\u200b<\/p>\n<p>});\u200b<\/p>\n<p>}\u200b<\/p>\n<p>});\u200b<\/p>\n<p>\u200b<\/p>\n<p>\u5728\u6a21\u677f\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u6307\u4ee4\u4e5f\u5f88\u65b9\u4fbf&#xff0c;\u4f8b\u5982\u6709\u4e00\u4e2a\u6309\u94ae&#xff0c;\u6211\u4eec\u5e0c\u671b\u70b9\u51fb\u540e\u9632\u6296 300 \u6beb\u79d2\u518d\u6267\u884c\u67d0\u4e2a\u65b9\u6cd5&#xff1a;\u200b<\/p>\n<p>\u200b<\/p>\n<p>TypeScript\u53d6\u6d88\u81ea\u52a8\u6362\u884c\u590d\u5236<\/p>\n<p>\u200b<\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c; v-debounce:300 \u8868\u793a\u5bf9\u6309\u94ae\u7684\u70b9\u51fb\u4e8b\u4ef6\u5e94\u7528\u9632\u6296\u6307\u4ee4&#xff0c;\u5ef6\u8fdf\u65f6\u95f4\u4e3a 300 \u6beb\u79d2\u3002\u5f53\u6309\u94ae\u88ab\u70b9\u51fb\u65f6&#xff0c;\u5728 300 \u6beb\u79d2\u5185\u5982\u679c\u518d\u6b21\u70b9\u51fb&#xff0c;\u4f1a\u6e05\u9664\u4e4b\u524d\u7684\u5b9a\u65f6\u5668&#xff0c;\u91cd\u65b0\u8ba1\u65f6&#xff0c;\u76f4\u5230 300 \u6beb\u79d2\u5185\u6ca1\u6709\u65b0\u7684\u70b9\u51fb&#xff0c;\u624d\u4f1a\u6267\u884c handleClick \u65b9\u6cd5\u3002\u200b<\/p>\n<p>\u8282\u6d41&#xff08;Throttle&#xff09;&#xff1a;\u9650\u5236\u9891\u7387&#xff0c;\u5e73\u7a33\u8fd0\u884c\u200b<\/p>\n<p>\u8282\u6d41\u7684\u6838\u5fc3\u539f\u7406\u200b<\/p>\n<p>\u8282\u6d41\u4e0e\u9632\u6296\u6709\u6240\u4e0d\u540c&#xff0c;\u5b83\u7684\u539f\u7406\u662f\u5728\u89c4\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u5185&#xff0c;\u65e0\u8bba\u4e8b\u4ef6\u88ab\u89e6\u53d1\u591a\u5c11\u6b21&#xff0c;\u90fd\u53ea\u4f1a\u6267\u884c\u4e00\u6b21\u6211\u4eec\u6307\u5b9a\u7684\u51fd\u6570\u3002\u53ef\u4ee5\u628a\u5b83\u770b\u4f5c\u662f\u4e00\u4e2a\u6d41\u91cf\u9650\u5236\u9600\u95e8&#xff0c;\u6309\u7167\u56fa\u5b9a\u7684\u9891\u7387\u653e\u884c\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u7684\u6267\u884c&#xff0c;\u4ece\u800c\u907f\u514d\u56e0\u4e8b\u4ef6\u9891\u7e41\u89e6\u53d1\u800c\u5bfc\u81f4\u7684\u6027\u80fd\u95ee\u9898\u3002\u200b<\/p>\n<p>React \u4e2d\u5b9e\u73b0\u8282\u6d41\u200b<\/p>\n<p>\u5728 React \u4e2d\u5b9e\u73b0\u8282\u6d41&#xff0c;\u540c\u6837\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u94a9\u5b50\u51fd\u6570\u6765\u5b8c\u6210\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u8282\u6d41\u94a9\u5b50\u51fd\u6570\u7684\u793a\u4f8b&#xff1a;\u200b<\/p>\n<p>\u200b<\/p>\n<p>TypeScript\u53d6\u6d88\u81ea\u52a8\u6362\u884c\u590d\u5236<\/p>\n<p>import { useCallback, useRef } from&#039;react&#039;;\u200b<\/p>\n<p>\u200b<\/p>\n<p>const useThrottle &#061; (callback, delay) &#061;&gt; {\u200b<\/p>\n<p>const timer &#061; useRef(null);\u200b<\/p>\n<p>const lastCallTime &#061; useRef(0);\u200b<\/p>\n<p>\u200b<\/p>\n<p>return useCallback((&#8230;args) &#061;&gt; {\u200b<\/p>\n<p>const now &#061; new Date().getTime();\u200b<\/p>\n<p>if (!timer.current &amp;&amp; now &#8211; lastCallTime.current &gt;&#061; delay) {\u200b<\/p>\n<p>callback(&#8230;args);\u200b<\/p>\n<p>lastCallTime.current &#061; now;\u200b<\/p>\n<p>timer.current &#061; setTimeout(() &#061;&gt; {\u200b<\/p>\n<p>timer.current &#061; null;\u200b<\/p>\n<p>}, delay &#8211; (now &#8211; lastCallTime.current));\u200b<\/p>\n<p>}\u200b<\/p>\n<p>}, [callback, delay]);\u200b<\/p>\n<p>};\u200b<\/p>\n<p>\u200b<\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u9875\u9762\u6eda\u52a8\u7684\u573a\u666f&#xff0c;\u9700\u8981\u5728\u6eda\u52a8\u8fc7\u7a0b\u4e2d\u6bcf\u9694 500 \u6beb\u79d2\u6267\u884c\u4e00\u6b21\u67d0\u4e2a\u64cd\u4f5c&#xff1a;\u200b<\/p>\n<p>\u200b<\/p>\n<p>TypeScript\u53d6\u6d88\u81ea\u52a8\u6362\u884c\u590d\u5236<\/p>\n<p>import React, { useEffect } from&#039;react&#039;;\u200b<\/p>\n<p>import useThrottle from &#039;.\/useThrottle&#039;;\u200b<\/p>\n<p>\u200b<\/p>\n<p>const ScrollComponent &#061; () &#061;&gt; {\u200b<\/p>\n<p>const handleScroll &#061; useThrottle(() &#061;&gt; {\u200b<\/p>\n<p>\/\/ \u8fd9\u91cc\u6267\u884c\u9875\u9762\u6eda\u52a8\u65f6\u7684\u5b9e\u9645\u64cd\u4f5c&#xff0c;\u4f8b\u5982\u83b7\u53d6\u5f53\u524d\u6eda\u52a8\u4f4d\u7f6e\u200b<\/p>\n<p>const scrollTop &#061; window.pageYOffset;\u200b<\/p>\n<p>console.log(&#039;Current scroll top:&#039;, scrollTop);\u200b<\/p>\n<p>}, 500);\u200b<\/p>\n<p>\u200b<\/p>\n<p>useEffect(() &#061;&gt; {\u200b<\/p>\n<p>window.addEventListener(&#039;scroll&#039;, handleScroll);\u200b<\/p>\n<p>return () &#061;&gt; {\u200b<\/p>\n<p>window.removeEventListener(&#039;scroll&#039;, handleScroll);\u200b<\/p>\n<p>};\u200b<\/p>\n<p>}, [handleScroll]);\u200b<\/p>\n<p>\u200b<\/p>\n<p>return (\u200b<\/p>\n<p>&lt;div style&#061;{{ height: &#039;2000px&#039; }}&gt;\u200b<\/p>\n<p>{\/* \u6a21\u62df\u4e00\u4e2a\u957f\u9875\u9762 *\/}\u200b<\/p>\n<p>&lt;\/div&gt;\u200b<\/p>\n<p>);\u200b<\/p>\n<p>};\u200b<\/p>\n<p>\u200b<\/p>\n<p>export default ScrollComponent;\u200b<\/p>\n<p>\u200b<\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c; useThrottle \u94a9\u5b50\u51fd\u6570\u901a\u8fc7\u8bb0\u5f55\u4e0a\u4e00\u6b21\u6267\u884c\u7684\u65f6\u95f4\u548c\u4f7f\u7528\u5b9a\u65f6\u5668&#xff0c;\u786e\u4fdd\u5728 500 \u6beb\u79d2\u7684\u65f6\u95f4\u95f4\u9694\u5185&#xff0c; handleScroll \u51fd\u6570\u53ea\u4f1a\u88ab\u6267\u884c\u4e00\u6b21&#xff0c;\u5373\u4f7f\u5728\u8fd9\u671f\u95f4\u9875\u9762\u6eda\u52a8\u4e8b\u4ef6\u88ab\u9891\u7e41\u89e6\u53d1\u3002\u200b<\/p>\n<p>Vue \u4e2d\u5b9e\u73b0\u8282\u6d41\u200b<\/p>\n<p>\u5728 Vue \u4e2d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6df7\u5165&#xff08;Mixin&#xff09;\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u8282\u6d41\u529f\u80fd&#xff0c;\u4ee5\u4fbf\u5728\u591a\u4e2a\u7ec4\u4ef6\u4e2d\u590d\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8282\u6d41\u6df7\u5165\u7684\u5b9e\u73b0&#xff1a;\u200b<\/p>\n<p>\u200b<\/p>\n<p>TypeScript\u53d6\u6d88\u81ea\u52a8\u6362\u884c\u590d\u5236<\/p>\n<p>\/\/ throttleMixin.js\u200b<\/p>\n<p>export const throttleMixin &#061; {\u200b<\/p>\n<p>methods: {\u200b<\/p>\n<p>throttle(func, delay) {\u200b<\/p>\n<p>let timer &#061; null;\u200b<\/p>\n<p>let lastCallTime &#061; 0;\u200b<\/p>\n<p>return function () {\u200b<\/p>\n<p>const now &#061; new Date().getTime();\u200b<\/p>\n<p>if (!timer &amp;&amp; now &#8211; lastCallTime &gt;&#061; delay) {\u200b<\/p>\n<p>func.apply(this, arguments);\u200b<\/p>\n<p>lastCallTime &#061; now;\u200b<\/p>\n<p>timer &#061; setTimeout(() &#061;&gt; {\u200b<\/p>\n<p>timer &#061; null;\u200b<\/p>\n<p>}, delay &#8211; (now &#8211; lastCallTime));\u200b<\/p>\n<p>}\u200b<\/p>\n<p>};\u200b<\/p>\n<p>}\u200b<\/p>\n<p>}\u200b<\/p>\n<p>};\u200b<\/p>\n<p>\u200b<\/p>\n<p>\u5728\u7ec4\u4ef6\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u6df7\u5165&#xff1a;\u200b<\/p>\n<p>\u200b<\/p>\n<p>TypeScript\u53d6\u6d88\u81ea\u52a8\u6362\u884c\u590d\u5236<\/p>\n<p>&lt;template&gt;\u200b<\/p>\n<p>&lt;div&gt;\u200b<\/p>\n<p>&lt;button &#064;click&#061;&#034;throttledClick&#034;&gt;\u70b9\u51fb\u6211&lt;\/button&gt;\u200b<\/p>\n<p>&lt;\/div&gt;\u200b<\/p>\n<p>&lt;\/template&gt;\u200b<\/p>\n<p>\u200b<\/p>\n<p>&lt;script&gt;\u200b<\/p>\n<p>import { throttleMixin } from &#039;.\/throttleMixin&#039;;\u200b<\/p>\n<p>\u200b<\/p>\n<p>export default {\u200b<\/p>\n<p>mixins: [throttleMixin],\u200b<\/p>\n<p>methods: {\u200b<\/p>\n<p>handleClick() {\u200b<\/p>\n<p>\/\/ \u8fd9\u91cc\u6267\u884c\u6309\u94ae\u70b9\u51fb\u540e\u7684\u5b9e\u9645\u903b\u8f91\u200b<\/p>\n<p>console.log(&#039;Button clicked&#039;);\u200b<\/p>\n<p>},\u200b<\/p>\n<p>throttledClick: null\u200b<\/p>\n<p>},\u200b<\/p>\n<p>created() {\u200b<\/p>\n<p>this.throttledClick &#061; this.throttle(this.handleClick, 500);\u200b<\/p>\n<p>}\u200b<\/p>\n<p>};\u200b<\/p>\n<p>&lt;\/script&gt;\u200b<\/p>\n<p>\u200b<\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;\u901a\u8fc7\u6df7\u5165 throttleMixin &#xff0c;\u7ec4\u4ef6\u83b7\u5f97\u4e86 throttle \u65b9\u6cd5\u3002\u5728 created \u94a9\u5b50\u51fd\u6570\u4e2d&#xff0c;\u5c06 handleClick \u65b9\u6cd5\u8fdb\u884c\u8282\u6d41\u5904\u7406&#xff0c;\u8bbe\u7f6e\u5ef6\u8fdf\u65f6\u95f4\u4e3a 500 \u6beb\u79d2&#xff0c;\u8fd9\u6837\u5728\u6309\u94ae\u88ab\u9891\u7e41\u70b9\u51fb\u65f6&#xff0c; handleClick \u65b9\u6cd5\u6bcf\u9694 500 \u6beb\u79d2\u53ea\u4f1a\u6267\u884c\u4e00\u6b21\u3002\u200b<\/p>\n<p>\u7efc\u5408\u8fd0\u7528&#xff0c;\u8ba9\u9875\u9762\u6027\u80fd\u98de\u5347\u200b<\/p>\n<p>\u901a\u8fc7\u5408\u7406\u5730\u8fd0\u7528\u9632\u6296\u548c\u8282\u6d41\u6280\u672f&#xff0c;\u6211\u4eec\u80fd\u591f\u6709\u6548\u5730\u89e3\u51b3 React \u548c Vue \u5e94\u7528\u4e2d\u56e0\u4e8b\u4ef6\u9891\u7e41\u89e6\u53d1\u800c\u5bfc\u81f4\u7684\u6027\u80fd\u95ee\u9898\u3002\u5728\u5b9e\u9645\u9879\u76ee\u4e2d&#xff0c;\u9700\u8981\u6839\u636e\u5177\u4f53\u7684\u4e1a\u52a1\u573a\u666f\u548c\u9700\u6c42&#xff0c;\u51c6\u786e\u5730\u9009\u62e9\u4f7f\u7528\u9632\u6296\u8fd8\u662f\u8282\u6d41&#xff0c;\u6216\u8005\u5728\u67d0\u4e9b\u590d\u6742\u573a\u666f\u4e0b&#xff0c;\u4e24\u8005\u7ed3\u5408\u4f7f\u7528\u3002\u4f8b\u5982&#xff0c;\u5728\u4e00\u4e2a\u5177\u6709\u81ea\u52a8\u5b8c\u6210\u529f\u80fd\u7684\u641c\u7d22\u6846\u4e2d&#xff0c;\u8f93\u5165\u8fc7\u7a0b\u4e2d\u7684\u8054\u60f3\u5efa\u8bae\u53ef\u4ee5\u4f7f\u7528\u9632\u6296\u6280\u672f&#xff0c;\u786e\u4fdd\u7528\u6237\u505c\u6b62\u8f93\u5165\u540e\u624d\u53d1\u8d77\u8bf7\u6c42\u83b7\u53d6\u5efa\u8bae&#xff1b;\u800c\u5f53\u7528\u6237\u5728\u641c\u7d22\u7ed3\u679c\u5217\u8868\u4e2d\u8fdb\u884c\u5feb\u901f\u6eda\u52a8\u6d4f\u89c8\u65f6&#xff0c;\u4e3a\u4e86\u907f\u514d\u9891\u7e41\u5730\u91cd\u65b0\u8ba1\u7b97\u548c\u6e32\u67d3\u5217\u8868\u9879&#xff0c;\u53ef\u4ee5\u5bf9\u6eda\u52a8\u4e8b\u4ef6\u4f7f\u7528\u8282\u6d41\u6280\u672f\u3002\u8fd9\u6837&#xff0c;\u901a\u8fc7\u5bf9\u4e0d\u540c\u4e8b\u4ef6\u7684\u7cbe\u51c6\u63a7\u5236&#xff0c;\u80fd\u591f\u663e\u8457\u63d0\u5347\u9875\u9762\u7684\u54cd\u5e94\u901f\u5ea6\u548c\u6d41\u7545\u5ea6&#xff0c;\u4e3a\u7528\u6237\u5e26\u6765\u5982\u5fb7\u8299\u822c\u4e1d\u6ed1\u7684\u4f7f\u7528\u4f53\u9a8c\u3002\u540c\u65f6&#xff0c;\u6211\u4eec\u4e5f\u8981\u6ce8\u610f&#xff0c;\u867d\u7136\u9632\u6296\u8282\u6d41\u662f\u5f3a\u5927\u7684\u6027\u80fd\u4f18\u5316\u5de5\u5177&#xff0c;\u4f46\u5b83\u4eec\u5e76\u975e\u4e07\u80fd\u7684\u3002\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d&#xff0c;\u8fd8\u9700\u8981\u7ed3\u5408\u5176\u4ed6\u4f18\u5316\u624b\u6bb5&#xff0c;\u5982\u4ee3\u7801\u5206\u5272\u3001\u61d2\u52a0\u8f7d\u3001\u5408\u7406\u7684\u72b6\u6001\u7ba1\u7406\u7b49&#xff0c;\u4ece\u591a\u4e2a\u7ef4\u5ea6\u5bf9\u5e94\u7528\u8fdb\u884c\u6027\u80fd\u4f18\u5316&#xff0c;\u6253\u9020\u51fa\u9ad8\u6027\u80fd\u3001\u9ad8\u8d28\u91cf\u7684 React \u548c Vue \u5e94\u7528\u3002\u200b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb354\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u53ef\u4ee5\u5c06\u5176\u60f3\u8c61\u6210\u4e00\u4e2a\u9632\u6296\u52a8\u7684\u5f00\u5173\uff0c\u5728\u9891\u7e41\u7684\u89e6\u53d1\u64cd\u4f5c\u4e2d\uff0c\u5b83\u4e0d\u4f1a\u7acb\u5373\u54cd\u5e94\uff0c\u800c\u662f\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u7684\u7a33\u5b9a\u671f\uff0c\u786e\u4fdd\u6ca1\u6709\u65b0\u7684\u89e6\u53d1\u540e\uff0c\u624d\u6267\u884c\u76f8\u5e94\u7684\u52a8\u4f5c\u3002\u5728 handleInputChange \u51fd\u6570\u4e2d\uff0c\u6bcf\u6b21\u8f93\u5165\u6846\u7684\u503c\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u90fd\u4f1a\u8c03\u7528 handleSearch \uff0c\u4f46\u7531\u4e8e\u9632\u6296\u7684\u4f5c\u7528\uff0c\u53ea\u6709\u5728\u7528\u6237\u505c\u6b62\u8f93\u5165 300 \u6beb\u79d2\u540e\uff0c handleSearch \u4e2d\u7684\u5b9e\u9645\u641c\u7d22\u903b\u8f91\u624d\u4f1a\u88ab\u6267\u884c\u3002\u5f53\u6309\u94ae\u88ab\u70b9\u51fb\u65f6\uff0c\u5728 300 \u6beb\u79d2\u5185\u5982\u679c\u518d\u6b21\u70b9\u51fb\uff0c\u4f1a\u6e05\u9664\u4e4b\u524d\u7684\u5b9a\u65f6\u5668\uff0c\u91cd\u65b0\u8ba1\u65f6\uff0c\u76f4\u5230 300 \u6beb\u79d2\u5185\u6ca1\u6709\u65b0\u7684\u70b9\u51fb\uff0c\u624d\u4f1a\u6267\u884c handleClick \u65b9\u6cd5\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[187,524,625],"topic":[],"class_list":["post-56613","post","type-post","status-publish","format-standard","hentry","category-server","tag-javascript","tag-react-js","tag-vue-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>React\/Vue \u6027\u80fd\u5d29\u4e86\uff1fJS \u9632\u6296\u8282\u6d41\u7ec8\u6781\u65b9\u6848\uff0c\u8ba9\u9875\u9762\u4e1d\u6ed1\u5982\u5fb7\u8299 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/56613.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"React\/Vue \u6027\u80fd\u5d29\u4e86\uff1fJS \u9632\u6296\u8282\u6d41\u7ec8\u6781\u65b9\u6848\uff0c\u8ba9\u9875\u9762\u4e1d\u6ed1\u5982\u5fb7\u8299 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb354\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u53ef\u4ee5\u5c06\u5176\u60f3\u8c61\u6210\u4e00\u4e2a\u9632\u6296\u52a8\u7684\u5f00\u5173\uff0c\u5728\u9891\u7e41\u7684\u89e6\u53d1\u64cd\u4f5c\u4e2d\uff0c\u5b83\u4e0d\u4f1a\u7acb\u5373\u54cd\u5e94\uff0c\u800c\u662f\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u7684\u7a33\u5b9a\u671f\uff0c\u786e\u4fdd\u6ca1\u6709\u65b0\u7684\u89e6\u53d1\u540e\uff0c\u624d\u6267\u884c\u76f8\u5e94\u7684\u52a8\u4f5c\u3002\u5728 handleInputChange \u51fd\u6570\u4e2d\uff0c\u6bcf\u6b21\u8f93\u5165\u6846\u7684\u503c\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u90fd\u4f1a\u8c03\u7528 handleSearch \uff0c\u4f46\u7531\u4e8e\u9632\u6296\u7684\u4f5c\u7528\uff0c\u53ea\u6709\u5728\u7528\u6237\u505c\u6b62\u8f93\u5165 300 \u6beb\u79d2\u540e\uff0c handleSearch \u4e2d\u7684\u5b9e\u9645\u641c\u7d22\u903b\u8f91\u624d\u4f1a\u88ab\u6267\u884c\u3002\u5f53\u6309\u94ae\u88ab\u70b9\u51fb\u65f6\uff0c\u5728 300 \u6beb\u79d2\u5185\u5982\u679c\u518d\u6b21\u70b9\u51fb\uff0c\u4f1a\u6e05\u9664\u4e4b\u524d\u7684\u5b9a\u65f6\u5668\uff0c\u91cd\u65b0\u8ba1\u65f6\uff0c\u76f4\u5230 300 \u6beb\u79d2\u5185\u6ca1\u6709\u65b0\u7684\u70b9\u51fb\uff0c\u624d\u4f1a\u6267\u884c handleClick \u65b9\u6cd5\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/56613.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-14T12:55:02+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56613.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/56613.html\",\"name\":\"React\/Vue \u6027\u80fd\u5d29\u4e86\uff1fJS \u9632\u6296\u8282\u6d41\u7ec8\u6781\u65b9\u6848\uff0c\u8ba9\u9875\u9762\u4e1d\u6ed1\u5982\u5fb7\u8299 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-14T12:55:02+00:00\",\"dateModified\":\"2025-08-14T12:55:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/56613.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/56613.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56613.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React\/Vue \u6027\u80fd\u5d29\u4e86\uff1fJS \u9632\u6296\u8282\u6d41\u7ec8\u6781\u65b9\u6848\uff0c\u8ba9\u9875\u9762\u4e1d\u6ed1\u5982\u5fb7\u8299\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"React\/Vue \u6027\u80fd\u5d29\u4e86\uff1fJS \u9632\u6296\u8282\u6d41\u7ec8\u6781\u65b9\u6848\uff0c\u8ba9\u9875\u9762\u4e1d\u6ed1\u5982\u5fb7\u8299 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/56613.html","og_locale":"zh_CN","og_type":"article","og_title":"React\/Vue \u6027\u80fd\u5d29\u4e86\uff1fJS \u9632\u6296\u8282\u6d41\u7ec8\u6781\u65b9\u6848\uff0c\u8ba9\u9875\u9762\u4e1d\u6ed1\u5982\u5fb7\u8299 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb354\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u53ef\u4ee5\u5c06\u5176\u60f3\u8c61\u6210\u4e00\u4e2a\u9632\u6296\u52a8\u7684\u5f00\u5173\uff0c\u5728\u9891\u7e41\u7684\u89e6\u53d1\u64cd\u4f5c\u4e2d\uff0c\u5b83\u4e0d\u4f1a\u7acb\u5373\u54cd\u5e94\uff0c\u800c\u662f\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u7684\u7a33\u5b9a\u671f\uff0c\u786e\u4fdd\u6ca1\u6709\u65b0\u7684\u89e6\u53d1\u540e\uff0c\u624d\u6267\u884c\u76f8\u5e94\u7684\u52a8\u4f5c\u3002\u5728 handleInputChange \u51fd\u6570\u4e2d\uff0c\u6bcf\u6b21\u8f93\u5165\u6846\u7684\u503c\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u90fd\u4f1a\u8c03\u7528 handleSearch \uff0c\u4f46\u7531\u4e8e\u9632\u6296\u7684\u4f5c\u7528\uff0c\u53ea\u6709\u5728\u7528\u6237\u505c\u6b62\u8f93\u5165 300 \u6beb\u79d2\u540e\uff0c handleSearch \u4e2d\u7684\u5b9e\u9645\u641c\u7d22\u903b\u8f91\u624d\u4f1a\u88ab\u6267\u884c\u3002\u5f53\u6309\u94ae\u88ab\u70b9\u51fb\u65f6\uff0c\u5728 300 \u6beb\u79d2\u5185\u5982\u679c\u518d\u6b21\u70b9\u51fb\uff0c\u4f1a\u6e05\u9664\u4e4b\u524d\u7684\u5b9a\u65f6\u5668\uff0c\u91cd\u65b0\u8ba1\u65f6\uff0c\u76f4\u5230 300 \u6beb\u79d2\u5185\u6ca1\u6709\u65b0\u7684\u70b9\u51fb\uff0c\u624d\u4f1a\u6267\u884c handleClick \u65b9\u6cd5\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/56613.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-14T12:55:02+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/56613.html","url":"https:\/\/www.wsisp.com\/helps\/56613.html","name":"React\/Vue \u6027\u80fd\u5d29\u4e86\uff1fJS \u9632\u6296\u8282\u6d41\u7ec8\u6781\u65b9\u6848\uff0c\u8ba9\u9875\u9762\u4e1d\u6ed1\u5982\u5fb7\u8299 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-14T12:55:02+00:00","dateModified":"2025-08-14T12:55:02+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/56613.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/56613.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/56613.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"React\/Vue \u6027\u80fd\u5d29\u4e86\uff1fJS \u9632\u6296\u8282\u6d41\u7ec8\u6781\u65b9\u6848\uff0c\u8ba9\u9875\u9762\u4e1d\u6ed1\u5982\u5fb7\u8299"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/56613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=56613"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/56613\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=56613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=56613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=56613"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=56613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}