{"id":15847,"date":"2024-10-26T14:02:04","date_gmt":"2024-10-26T06:02:04","guid":{"rendered":"https:\/\/123proxy.cn\/blogs\/2024\/10\/javascript-%e4%b8%ad%e7%9a%84-proxy-%e4%bb%a3%e7%90%86%ef%bc%9a%e6%b7%b1%e5%85%a5%e5%ae%9e%e8%b7%b5%e4%b8%8e%e6%8a%80%e5%b7%a7\/"},"modified":"2024-10-26T14:02:04","modified_gmt":"2024-10-26T06:02:04","slug":"javascript-%e4%b8%ad%e7%9a%84-proxy-%e4%bb%a3%e7%90%86%ef%bc%9a%e6%b7%b1%e5%85%a5%e5%ae%9e%e8%b7%b5%e4%b8%8e%e6%8a%80%e5%b7%a7","status":"publish","type":"post","link":"https:\/\/123proxy.cn\/blogs\/2024\/10\/javascript-%e4%b8%ad%e7%9a%84-proxy-%e4%bb%a3%e7%90%86%ef%bc%9a%e6%b7%b1%e5%85%a5%e5%ae%9e%e8%b7%b5%e4%b8%8e%e6%8a%80%e5%b7%a7\/","title":{"rendered":"JavaScript \u4e2d\u7684 Proxy \u4ee3\u7406\uff1a\u6df1\u5165\u5b9e\u8df5\u4e0e\u6280\u5de7"},"content":{"rendered":"<p>\u4f60\u662f\u5426\u66fe\u60f3\u8fc7\u5982\u4f55\u901a\u8fc7 JavaScript \u63d0\u5347\u5e94\u7528\u7684<strong>\u6027\u80fd<\/strong>\u4e0e<strong>\u5b89\u5168<\/strong>\uff1f\u5728\u73b0\u4ee3<strong>\u7f51\u7edc\u4ee3\u7406<\/strong>\u7684\u4e16\u754c\u4e2d\uff0c<strong>Proxy<\/strong> \u4ee3\u7406\u6210\u4e3a\u4e86\u65e0\u4ef7\u4e4b\u5b9d\uff0c\u5c24\u5176\u5728 JavaScript \u7684\u5e94\u7528\u4e2d\u3002<\/p>\n<p>\u672c\u6587\u5c06\u5e26\u4f60\u8d70\u8fdb JavaScript \u4e2d\u7684 Proxy \u4ee3\u7406\uff0c\u901a\u8fc7\u8be6\u7ec6\u7684\u5b9e\u4f8b\u548c\u6280\u5de7\uff0c\u63ed\u793a\u8fd9\u4e00\u5f3a\u5927\u5de5\u5177\u5982\u4f55\u9769\u65b0\u60a8\u7684\u5f00\u53d1\u4f53\u9a8c\u3002\u4ece\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684 <strong>HTTP<\/strong> \u4ee3\u7406\uff0c\u5230\u6df1\u5ea6\u5256\u6790 trap \u65b9\u6cd5\u4ee5\u53ca\u5b83\u4eec\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u8868\u73b0\uff0c\u6211\u4eec\u63d0\u4f9b\u7684\u4e0d\u4ec5\u662f\u7406\u8bba\uff0c\u66f4\u662f\u5b9e\u8df5\u3002<\/p>\n<p>\u5982\u4f55\u5728\u9879\u76ee\u4e2d\u5408\u7406\u5229\u7528 <strong>Proxy<\/strong> \u63d0\u5347\u6027\u80fd\uff1f\u600e\u6837\u5728\u5927\u578b\u9879\u76ee\u4e2d\u8f7b\u677e\u7ba1\u7406<strong>state<\/strong>\uff1f\u7ed3\u5408 <strong>Vue.js<\/strong> \u548c <strong>React<\/strong>\uff0c<strong>Proxy<\/strong> \u53c8\u80fd\u5e26\u6765\u4ec0\u4e48\u6837\u7684\u60ca\u559c\uff1f\u8fd9\u4e9b\u95ee\u9898\u5c06\u5728\u672c\u7bc7\u6587\u7ae0\u5f97\u5230\u89e3\u7b54\u3002<\/p>\n<p>\u901a\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5f00\u53d1\u4eba\u5458\u548c\u6280\u672f\u7231\u597d\u8005\u4eec\u5c06\u5168\u9762\u638c\u63e1 JavaScript Proxy \u4ee3\u7406\u7684\u4f7f\u7528\u4e4b\u9053\uff0c\u5f00\u542f\u9ad8\u6548\u5f00\u53d1\u7684\u65b0\u7bc7\u7ae0\u3002<\/p>\n<h2>\u5173\u952e\u8981\u70b9<\/h2>\n<ul>\n<li>JavaScript \u4e2d\u7684 Proxy \u4ee3\u7406\u4e3a\u5f00\u53d1\u4eba\u5458\u63d0\u4f9b\u4e86\u4e00\u79cd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u4ee5\u66f4\u7075\u6d3b\u5730\u63a7\u5236\u5bf9\u8c61\u7684\u884c\u4e3a\u3002<\/li>\n<li>Proxy \u4e0e\u666e\u901a\u5bf9\u8c61\u7684\u533a\u522b\u4e3b\u8981\u5728\u4e8e\u5176\u80fd\u591f\u62e6\u622a\u548c\u6539\u5199\u591a\u79cd\u64cd\u4f5c\uff0c\u4f7f\u5f00\u53d1\u8005\u80fd\u591f\u9ad8\u6548\u5904\u7406\u6570\u636e\u9a8c\u8bc1\u548c\u6027\u80fd\u4f18\u5316\u3002<\/li>\n<li>\u901a\u8fc7\u5408\u7406\u4f7f\u7528 Proxy \u7684 trap \u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u80fd\u591f\u66f4\u597d\u5730\u7ba1\u7406\u6570\u636e\u7684\u83b7\u53d6\u548c\u8bbe\u7f6e\u3002<\/li>\n<li>Proxy \u5728\u9879\u76ee\u4e2d\u7684\u5e94\u7528\u4e0d\u4ec5\u80fd\u591f\u63d0\u5347\u6027\u80fd\uff0c\u8fd8\u80fd\u591f\u6709\u6548\u7ba1\u7406\u72b6\u6001\u7279\u522b\u662f\u5728\u5927\u578b\u9879\u76ee\u4e2d\u3002<\/li>\n<li>\u5728\u4e0e\u73b0\u4ee3\u6846\u67b6\uff08\u5982 Vue.js \u548c React\uff09\u7ed3\u5408\u4f7f\u7528\u65f6\uff0cProxy \u53ef\u4ee5\u6539\u5584\u5f00\u53d1\u4f53\u9a8c\u5e76\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u3002<\/li>\n<li>\u7406\u89e3 Proxy \u7684\u5b89\u5168\u8003\u91cf\u53ca\u6f5c\u5728\u9690\u60a3\u5bf9\u4e8e\u4fdd\u62a4\u7528\u6237\u6570\u636e\u548c\u9632\u6b62\u6ee5\u7528\u81f3\u5173\u91cd\u8981\u3002<\/li>\n<\/ul>\n<h2>JavaScript \u4e2d\u7684 Proxy \u4ee3\u7406\u6982\u8ff0<\/h2>\n<h3>Proxy \u7684\u57fa\u672c\u6982\u5ff5<\/h3>\n<p><strong>Proxy<\/strong> \u662f JavaScript \u4e2d\u7684\u4e00\u4e2a\u5185\u7f6e\u5bf9\u8c61\uff0c\u80fd\u591f\u521b\u5efa\u4e00\u4e2a\u4ee3\u7406\u6765\u62e6\u622a\u548c\u5b9a\u5236\u5bf9\u76ee\u6807\u5bf9\u8c61\u7684\u57fa\u672c\u64cd\u4f5c\u3002\u8fd9\u4e9b\u64cd\u4f5c\u5305\u62ec<em>\u83b7\u53d6<\/em>\u3001<em>\u8bbe\u7f6e<\/em>\u3001<em>\u5220\u9664<\/em>\u5c5e\u6027\uff0c\u4ee5\u53ca\u6267\u884c<em>\u51fd\u6570\u8c03\u7528<\/em>\u7b49\u3002\u901a\u8fc7\u4f7f\u7528 <strong>Proxy<\/strong>\uff0c\u5f00\u53d1\u4eba\u5458\u80fd\u591f\u589e\u5f3a\u5176\u5e94\u7528\u7a0b\u5e8f\u7684\u7075\u6d3b\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<p>\u5177\u4f53\u800c\u8a00\uff0c\u4f7f\u7528 <strong>Proxy<\/strong> \u53ef\u4ee5\u5b9e\u73b0\u5bf9\u6570\u636e\u7684\u66f4\u7cbe\u7ec6\u7684\u63a7\u5236\u3002\u5f53\u7528\u6237\u5bf9\u76ee\u6807\u5bf9\u8c61\u8fdb\u884c\u67d0\u4e9b\u64cd\u4f5c\u65f6\uff0c\u4ee3\u7406\u80fd\u591f\u6355\u83b7\u8fd9\u4e9b\u64cd\u4f5c\u5e76\u63d0\u4f9b\u81ea\u5b9a\u4e49\u884c\u4e3a\uff0c\u4f8b\u5982\u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\u3001\u65e5\u5fd7\u8bb0\u5f55\u6216\u8bbf\u95ee\u63a7\u5236\u3002\u8fd9\u79cd\u673a\u5236\u663e\u8457\u63d0\u5347\u4e86\u5f00\u53d1\u4eba\u5458\u5728\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u7684<em>\u7075\u6d3b\u6027<\/em>\u3002<\/p>\n<h3>\u4ee3\u7406\u4e0e\u666e\u901a\u5bf9\u8c61\u7684\u533a\u522b<\/h3>\n<p>\u4e0e\u666e\u901a\u5bf9\u8c61\u76f8\u6bd4\uff0c<strong>Proxy<\/strong> \u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u529f\u80fd\u3002\u4f8b\u5982\uff0c\u666e\u901a\u5bf9\u8c61\u6ca1\u6709\u5185\u7f6e\u7684\u673a\u5236\u6765\u62e6\u622a\u5c5e\u6027\u8bbf\u95ee\uff0c\u800c <strong>Proxy<\/strong> \u5219\u5177\u5907\u8fd9\u79cd\u80fd\u529b\u3002\u5728\u666e\u901a\u5bf9\u8c61\u4e2d\uff0c\u5c5e\u6027\u8bbf\u95ee\u53ea\u80fd\u76f4\u63a5\u8fdb\u884c\uff0c\u800c <strong>Proxy<\/strong> \u53ef\u4ee5\u5728\u8fd9\u4e9b\u64cd\u4f5c\u524d\u540e\u52a0\u5165\u81ea\u5b9a\u4e49\u7684\u903b\u8f91\u3002<\/p>\n<p>\u6b64\u5916\uff0c<strong>Proxy<\/strong> \u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u4e3a\u64cd\u4f5c\u5b9a\u4e49\u4e0d\u540c\u7684\u62e6\u622a\u5668\u3002\u5177\u4f53\u800c\u8a00\uff0c<strong>Proxy<\/strong> \u652f\u6301\u591a\u4e2a\u9677\u9631\uff08traps\uff09\uff0c\u4f8b\u5982 <em>get<\/em>\u3001<em>set<\/em> \u548c <em>has<\/em>\uff0c\u7528\u4e8e\u5b9a\u4e49\u5982\u4f55\u5904\u7406\u8fd9\u4e9b\u64cd\u4f5c\u3002\u8fd9\u4f7f\u5f97<em>Proxy<\/em> \u5728\u5b9e\u73b0\u590d\u6742\u7684\u8bbe\u8ba1\u6a21\u5f0f\uff08\u5982 <strong>\u89c2\u5bdf\u8005\u6a21\u5f0f<\/strong>\uff09\u65f6\u8868\u73b0\u5f97\u5c24\u4e3a\u51fa\u8272\u3002<\/p>\n<h3>\u4f7f\u7528 Proxy \u7684\u5e38\u89c1\u573a\u666f<\/h3>\n<p>\u5f00\u53d1\u4eba\u5458\u901a\u5e38\u5728\u591a\u79cd\u573a\u666f\u4e0b\u4f7f\u7528 <strong>Proxy<\/strong>\u3002\u5176\u4e2d\u5305\u62ec\u6570\u636e\u9a8c\u8bc1\u3001\u54cd\u5e94\u5f0f\u7f16\u7a0b\u3001\u4ee5\u53ca\u5b9e\u73b0\u4e00\u4e9b\u66f4\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\u3002\u4f7f\u7528 <strong>Proxy<\/strong>\uff0c\u4ed6\u4eec\u53ef\u4ee5\u5feb\u901f\u54cd\u5e94\u7528\u6237\u7684\u8f93\u5165\uff0c\u63d0\u9ad8\u5e94\u7528\u7a0b\u5e8f\u7684 <strong>\u7528\u6237\u4f53\u9a8c<\/strong>\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5728\u6784\u5efa\u6570\u636e\u7ed1\u5b9a\u6846\u67b6\u65f6\uff0c\u4f7f\u7528 <strong>Proxy<\/strong> \u53ef\u4ee5\u5b9e\u73b0\u5c5e\u6027\u66f4\u6539\u7684\u5b9e\u65f6\u76d1\u63a7\uff0c\u4ece\u800c\u786e\u4fdd\u7528\u6237\u754c\u9762\u80fd\u591f\u5feb\u901f\u53cd\u6620\u6570\u636e\u7684\u53d8\u5316\u3002\u8fd9\u79cd\u6280\u672f\u5728\u73b0\u4ee3\u524d\u7aef\u6846\u67b6\uff08\u5982 Vue.js \u548c React.js\uff09\u4e2d\u8d8a\u6765\u8d8a\u88ab\u5e7f\u6cdb\u4f7f\u7528\u3002<\/p>\n<h3>Proxy \u5728\u73b0\u4ee3 JavaScript \u4e2d\u7684\u53d1\u5c55<\/h3>\n<p>\u8fd1\u5e74\u6765\uff0c<strong>Proxy<\/strong> \u5728 JavaScript \u4e2d\u7684\u4f7f\u7528\u4e0d\u65ad\u589e\u52a0\u3002\u968f\u7740 ECMAScript \u7684\u66f4\u65b0\uff0c\u66f4\u591a\u7684\u65b0\u7279\u6027\u548c <strong>API<\/strong> \u96c6\u6210\u8fdb <strong>Proxy<\/strong>\uff0c\u4f7f\u5176\u5728\u6570\u636e\u5904\u7406\u548c\u7f51\u7edc\u8bf7\u6c42\u4e2d\u7684\u5e94\u7528\u66f4\u4e3a\u5e7f\u6cdb\u3002<\/p>\n<p>\u6b64\u5916\uff0c<strong>Proxy<\/strong> \u7684\u5f15\u5165\u4f7f\u5f97\u5f00\u53d1\u4eba\u5458\u80fd\u591f\u66f4\u5bb9\u6613\u5b9e\u73b0\u590d\u6742\u7684\u7cfb\u7edf\uff0c\u5982\u8d1f\u8f7d\u5747\u8861\u548c\u6d41\u91cf\u7ba1\u7406\u3002\u8fd9\u5bf9\u4e8e\u9700\u8981\u9ad8\u53ef\u7528\u6027\u4e0e\u9ad8\u6027\u80fd\u7684\u4f01\u4e1a\u7ea7\u5e94\u7528\u5c24\u5176\u91cd\u8981\u3002\u901a\u8fc7\u5229\u7528 <strong>Proxy<\/strong>\uff0c\u5f00\u53d1\u4eba\u5458\u8fd8\u53ef\u4ee5\u66f4\u597d\u5730\u5b9e\u73b0\u6570\u636e\u9690\u79c1\u548c\u5b89\u5168\u6027\uff0c\u964d\u4f4e\u6f5c\u5728\u7684\u7f51\u7edc\u653b\u51fb\u98ce\u9669\u3002<\/p>\n<h2>\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684 JavaScript Proxy <\/h2>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/123proxy.cn\/blogs\/wp-content\/uploads\/2024\/10\/57165c58-817e-4f84-80e4-c5d07fbf4a15.jpeg\" alt=\"RAW photo, a close-up of a computer screen displaying network configurations with proxy server settings, intricate circuit patterns in the background, soft blue lighting creating a techy atmosphere, 8k UHD, high-quality image, detailed texture\" width=650 height=430><\/figure>\n<h3>Proxy \u6784\u9020\u51fd\u6570\u7684\u4f7f\u7528<\/h3>\n<p>\u5728 JavaScript \u4e2d\uff0c<strong>Proxy<\/strong> \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u901a\u8fc7\u4ee3\u7406\u6765\u62e6\u622a\u5bf9\u5bf9\u8c61\u7684\u64cd\u4f5c\u3002\u4f7f\u7528 <strong>Proxy<\/strong> \u6784\u9020\u51fd\u6570\uff0c\u7528\u6237\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4ee3\u7406\u5bf9\u8c61\uff0c\u5e76\u4e14\u6307\u5b9a\u8be5\u5bf9\u8c61\u7684\u76ee\u6807\u548c\u5904\u7406\u7a0b\u5e8f\u3002\u901a\u8fc7\u8fd9\u6837\u7684\u65b9\u5f0f\uff0c\u5f00\u53d1\u8005\u80fd\u591f\u81ea\u5b9a\u4e49\u5bf9\u5bf9\u8c61\u5c5e\u6027\u7684\u8bbf\u95ee\u548c\u64cd\u4f5c\uff0c\u4ece\u800c\u589e\u5f3a\u4e86\u7075\u6d3b\u6027\u548c\u529f\u80fd\u6027\u3002<\/p>\n<p>\u4ee3\u7406\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<br \/>\n<code>const proxy = new Proxy(target, handler);<\/code> \u5176\u4e2d <strong>target<\/strong> \u662f\u9700\u8981\u88ab\u4ee3\u7406\u7684\u539f\u59cb\u5bf9\u8c61\uff0c\u800c <strong>handler<\/strong> \u5219\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5b83\u5305\u542b\u4e86\u7528\u4e8e\u62e6\u622a\u5bf9\u8c61\u64cd\u4f5c\u7684\u51fd\u6570\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u4ee3\u7406\u4f1a\u76d1\u542c\u5230\u5bf9\u4e8e\u76ee\u6807\u5bf9\u8c61\u7684\u6240\u6709\u64cd\u4f5c\uff0c\u5982\u8bfb\u53d6\u5c5e\u6027\u3001\u8d4b\u503c\u3001\u51fd\u6570\u8c03\u7528\u7b49\uff0c\u4ece\u800c\u5f00\u53d1\u8005\u80fd\u591f\u5728\u8fd9\u4e9b\u64cd\u4f5c\u4e4b\u524d\u6216\u4e4b\u540e\uff0c\u63d2\u5165\u81ea\u5b9a\u4e49\u7684\u903b\u8f91\u3002<\/p>\n<h3>target \u4e0e handler \u7684\u5b9a\u4e49<\/h3>\n<p>\u5728\u521b\u5efa\u4ee3\u7406\u65f6\uff0c<strong>target<\/strong> \u548c <strong>handler<\/strong> \u662f\u4e24\u4e2a\u4e3b\u8981\u53c2\u6570\u3002<strong>target<\/strong> \u662f\u6307\u5411\u8981\u4ee3\u7406\u7684\u5bf9\u8c61\uff0c\u4f8b\u5982\uff1a\u4e00\u4e2a\u7b80\u5355\u7684 JavaScript \u5bf9\u8c61\uff0c\u6216\u662f\u6570\u7ec4\u3002<\/p>\n<p><strong>handler<\/strong> \u662f\u53e6\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5b83\u5b9a\u4e49\u4e86\u62e6\u622a\u5668\u3002\u6bcf\u4e2a\u62e6\u622a\u5668\u90fd\u662f\u4e00\u4e2a\u65b9\u6cd5\uff0c\u5b83\u4eec\u53ef\u4ee5\u62e6\u622a\u5404\u7c7b\u64cd\u4f5c\uff0c\u6bd4\u5982\u83b7\u53d6\u5c5e\u6027\u3001\u8bbe\u7f6e\u5c5e\u6027\u3001\u51fd\u6570\u8c03\u7528\u7b49\u3002\u6700\u5e38\u89c1\u7684\u62e6\u622a\u5668\u5305\u62ec <strong>get<\/strong> \u548c <strong>set<\/strong> \u65b9\u6cd5\u3002\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u80fd\u591f\u5b9e\u73b0\u590d\u6742\u7684\u903b\u8f91\u63a7\u5236\uff0c\u4f8b\u5982\u6743\u9650\u9a8c\u8bc1\u6216\u5c5e\u6027\u4fee\u6539\u7b49\u3002<\/p>\n<h3>\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u4ee3\u7406\u7684\u5b9e\u4f8b<\/h3>\n<p>\u4e3a\u4e86\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7406\uff0c\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u4ee3\u7801\u793a\u4f8b\uff1a<br \/>\n<code>const target = { message: 'Hello, world!' };<br \/>\nconst handler = {<br \/>\n    get: function(target, property) {<br \/>\n        return property in target ? target[property] : 'not found';<br \/>\n    }<br \/>\n};<br \/>\nconst proxy = new Proxy(target, handler);<br \/>\nconsole.log(proxy.message); \/\/ \u8f93\u51fa: Hello, world!<br \/>\nconsole.log(proxy.nonExistent); \/\/ \u8f93\u51fa: not found<\/code><\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u4ee3\u7801\uff0c\u5f00\u53d1\u8005\u5b9a\u4e49\u4e86\u4e00\u4e2a\u4ee3\u7406\uff0c\u5b83\u80fd\u591f\u6b63\u5e38\u83b7\u53d6\u76ee\u6807\u5bf9\u8c61\u7684\u5c5e\u6027\uff0c\u5e76\u4e14\u5728\u672a\u627e\u5230\u8be5\u5c5e\u6027\u65f6\u8fd4\u56de\u81ea\u5b9a\u4e49\u7684\u6d88\u606f\u3002\u8fd9\u79cd\u57fa\u672c\u7684\u4ee3\u7406\u5b9e\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528 <strong>Proxy<\/strong>\uff0c\u4ece\u800c\u6269\u5c55\u5bf9\u8c61\u7684\u529f\u80fd\u3002<\/p>\n<h3>\u5e38\u89c1\u7684 handler \u65b9\u6cd5<\/h3>\n<p>\u5728\u5b9e\u8df5\u4e2d\uff0c\u6709\u8bb8\u591a\u5e38\u7528\u7684 handler \u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5b9e\u73b0\u7279\u5b9a\u7684\u9700\u6c42\u3002\u8fd9\u4e9b\u65b9\u6cd5\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>get<\/strong>\uff1a\u7528\u4e8e\u62e6\u622a\u5bf9\u5c5e\u6027\u7684\u8bfb\u53d6\u64cd\u4f5c\u3002<\/li>\n<li><strong>set<\/strong>\uff1a\u7528\u4e8e\u62e6\u622a\u5bf9\u5c5e\u6027\u7684\u8d4b\u503c\u64cd\u4f5c\u3002<\/li>\n<li><strong>has<\/strong>\uff1a\u7528\u4e8e\u62e6\u622a <strong>in<\/strong> \u8fd0\u7b97\u7b26\u3002<\/li>\n<li><strong>deleteProperty<\/strong>\uff1a\u7528\u4e8e\u62e6\u622a\u5bf9\u5c5e\u6027\u7684\u5220\u9664\u64cd\u4f5c\u3002<\/li>\n<li><strong>apply<\/strong>\uff1a\u7528\u4e8e\u62e6\u622a\u51fd\u6570\u7684\u8c03\u7528\u3002<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b handler \u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5b9e\u73b0\u7f13\u5b58\u3001\u6570\u636e\u9a8c\u8bc1\u3001\u8bbf\u95ee\u63a7\u5236\u7b49\u591a\u79cd\u529f\u80fd\u3002\u5bf9\u4e8e\u9700\u8981\u201c<strong>\u4ee3\u7406<\/strong>\u201d\u7684\u590d\u6742\u573a\u666f\uff0c\u9ad8\u6548\u7684 handler \u65b9\u6cd5\u80fd\u663e\u8457\u63d0\u9ad8\u7f51\u7edc\u5b89\u5168\u6027\u548c\u6027\u80fd\u8868\u73b0\u3002<\/p>\n<h2>\u6df1\u5165\u4e86\u89e3 Proxy \u7684 trap \u65b9\u6cd5<\/h2>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/123proxy.cn\/blogs\/wp-content\/uploads\/2024\/10\/602ce344-f3c5-4a94-b985-259d07dc837a.jpeg\" alt=\"RAW photo, an abstract representation of internet security, featuring a digital lock and proxy servers symbolizing protection and anonymity, illuminated with vibrant neon colors, 8k UHD, high-resolution image that conveys a futuristic tech vibe\" width=650 height=430><\/figure>\n<h3>get \u548c set trap<\/h3>\n<p>\u5728 JavaScript \u4e2d\uff0c<strong>Proxy<\/strong> \u63d0\u4f9b\u4e86\u4e00\u79cd\u7075\u6d3b\u7684\u65b9\u5f0f\u6765\u5904\u7406\u5bf9\u8c61\u5c5e\u6027\u7684\u8bbf\u95ee\u4e0e\u4fee\u6539\u3002<strong>get<\/strong> \u548c <strong>set<\/strong> trap \u65b9\u6cd5\u662f\u5176\u4e2d\u6700\u57fa\u672c\u4e14\u6700\u91cd\u8981\u7684\u7279\u6027\u3002\u8fd9\u4e9b trap \u65b9\u6cd5\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u62e6\u622a\u5bf9\u5bf9\u8c61\u5c5e\u6027\u7684\u8bfb\u53d6\u4e0e\u4fee\u6539\uff0c\u4ece\u800c\u589e\u5f3a\u5e94\u7528\u7a0b\u5e8f\u7684\u7075\u6d3b\u6027\u3002<\/p>\n<p>\u5229\u7528 <strong>get<\/strong> trap\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u5b9a\u4e49\u5982\u4f55\u83b7\u53d6\u5bf9\u8c61\u7684\u5c5e\u6027\u503c\u3002\u8fd9\u5728\u5b9e\u73b0\u6570\u636e\u7ed1\u5b9a\u6216\u4e3a\u7279\u5b9a\u7684\u5c5e\u6027\u5b9e\u73b0\u60f0\u6027\u52a0\u8f7d\u65f6\u7279\u522b\u6709\u7528\u3002\u540c\u65f6\uff0c<strong>set<\/strong> trap \u4e3a\u5c5e\u6027\u8d4b\u503c\u63d0\u4f9b\u4e86\u989d\u5916\u7684\u63a7\u5236\u624b\u6bb5\uff0c\u80fd\u591f\u5b9e\u73b0\u6570\u636e\u9a8c\u8bc1\u3001\u683c\u5f0f\u5316\u6216\u89e6\u53d1\u5176\u4ed6\u526f\u4f5c\u7528\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u4f7f\u7528 <strong>set<\/strong> trap \u6765\u9650\u5236\u67d0\u4e2a\u5c5e\u6027\u53ea\u63a5\u53d7\u7279\u5b9a\u7c7b\u578b\u7684\u503c\uff0c\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<blockquote>\n<pre>const handler = { set: function(obj, prop, value) { if (typeof value !== 'string') { throw new Error('\u5c5e\u6027\u503c\u5fc5\u987b\u4e3a\u5b57\u7b26\u4e32'); } obj[prop] = value; return true; }};<\/pre>\n<\/blockquote>\n<h3>apply \u548c construct trap<\/h3>\n<p>\u5728 JavaScript \u4e2d\uff0c<strong>apply<\/strong> \u548c <strong>construct<\/strong> trap \u662f\u7528\u4e8e\u62e6\u622a\u51fd\u6570\u8c03\u7528\u7684\u4e24\u79cd\u91cd\u8981\u673a\u5236\u3002\u901a\u8fc7\u8fd9\u4e24\u79cd trap\uff0c\u5f00\u53d1\u4eba\u5458\u80fd\u591f\u638c\u63a7\u51fd\u6570\u7684\u8c03\u7528\u65b9\u5f0f\u53ca\u6784\u9020\u51fd\u6570\u7684\u5b9e\u4f8b\u5316\u8fc7\u7a0b\u3002<strong>apply<\/strong> trap \u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u5b9a\u4e49\u51fd\u6570\u88ab\u8c03\u7528\u65f6\u7684\u4e0a\u4e0b\u6587\u548c\u53c2\u6570\uff0c\u800c <strong>construct<\/strong> trap \u5219\u7528\u4e8e\u62e6\u622a\u6784\u9020\u51fd\u6570\u7684\u8c03\u7528\uff0c\u4f7f\u5f97\u5176\u751f\u6210\u7684\u5b9e\u4f8b\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<p>\u8fd9\u5bf9\u4e8e\u8fdb\u884c\u590d\u6742\u7684\u64cd\u4f5c\uff0c\u6bd4\u5982\u5b9e\u73b0\u51fd\u6570\u7684\u7f13\u5b58\u6216\u52a8\u6001\u8c03\u6574\u5b9e\u4f8b\u7684\u5c5e\u6027\u975e\u5e38\u6709\u5e2e\u52a9\u3002\u4f8b\u5982\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u901a\u8fc7 <strong>apply<\/strong> trap \u5728\u4e0d\u6539\u53d8\u51fd\u6570\u672c\u8eab\u7684\u60c5\u51b5\u4e0b\uff0c\u589e\u52a0\u989d\u5916\u7684\u53c2\u6570\uff0c\u6216\u8005\u4e3a\u51fd\u6570\u8c03\u7528\u63d0\u4f9b\u7279\u5b9a\u7684\u4e0a\u4e0b\u6587\u73af\u5883\u3002<\/p>\n<h3>deleteProperty \u548c has trap<\/h3>\n<p>\u9664\u6b64\u4e4b\u5916\uff0c<strong>deleteProperty<\/strong> \u548c <strong>has<\/strong> trap \u4e5f\u4e3a\u5bf9\u8c61\u64cd\u4f5c\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7a0b\u5ea6\u7684\u63a7\u5236\u3002\u901a\u8fc7 <strong>deleteProperty<\/strong> trap\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u62e6\u622a\u5c5e\u6027\u7684\u5220\u9664\u64cd\u4f5c\uff0c\u8fd9\u610f\u5473\u7740\u4ed6\u4eec\u53ef\u4ee5\u6dfb\u52a0\u989d\u5916\u7684\u9a8c\u8bc1\u6216\u89e6\u53d1\u5176\u4ed6\u903b\u8f91\u3002\u540c\u65f6\uff0c<strong>has<\/strong> trap \u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u63a7\u5236\u5bf9\u8c61\u4e2d\u5c5e\u6027\u7684\u5b58\u5728\u6027\u68c0\u6d4b\uff0c\u8fd9\u4e3a\u5b9e\u73b0\u4e00\u4e9b\u9690\u79c1\u4fdd\u62a4\u673a\u5236\u63d0\u4f9b\u4e86\u53ef\u80fd\u3002<\/p>\n<h3>\u5176\u4ed6\u5b9e\u7528\u7684 trap \u65b9\u6cd5<\/h3>\n<p>\u9664\u4e86\u4e0a\u8ff0 trap \u65b9\u6cd5\uff0cProxy \u8fd8\u6709\u8bb8\u591a\u5176\u4ed6\u7c7b\u578b\u7684\u65b9\u6cd5\uff0c\u4f8b\u5982 <strong>ownKeys<\/strong> \u7528\u4e8e\u62e6\u622a\u5bf9\u8c61\u7684\u952e\u7684\u8bbf\u95ee\uff0c\u4ee5\u53ca <strong>getOwnPropertyDescriptor<\/strong> \u7528\u4e8e\u5b9a\u4e49\u5c5e\u6027\u63cf\u8ff0\u7b26\u3002\u8fd9\u4e9b\u65b9\u6cd5\u5728\u5b9e\u73b0\u590d\u6742\u7684\u903b\u8f91\u65f6\uff0c\u5c24\u5176\u662f\u5728\u6d89\u53ca\u5230 <strong>\u7f51\u7edc\u4ee3\u7406<\/strong> \u548c\u6570\u636e\u5b89\u5168\u7684\u573a\u666f\u4e0b\uff0c\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002\u901a\u8fc7\u5408\u7406\u4f7f\u7528\u8fd9\u4e9b trap \u65b9\u6cd5\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u6253\u9020\u51fa\u66f4\u9ad8\u6548\u3001\u66f4\u5b89\u5168\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u786e\u4fdd\u5728\u8bbf\u95ee\u4e0e\u5904\u7406 <strong>\u7528\u6237\u6570\u636e<\/strong> \u65f6\u63d0\u9ad8\u9690\u79c1\u548c\u5b89\u5168\u6027\u3002<\/p>\n<h2>Proxy \u4ee3\u7406\u7684\u5b9e\u7528\u6280\u5de7\u4e0e\u8fdb\u9636<\/h2>\n<p><iframe style=\"aspect-ratio: 16 \/ 9; width: 100%\" src=\"https:\/\/www.youtube.com\/embed\/cSXPB6GDKdQ\" title=\"cSXPB6GDKdQ\" frameBorder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowFullScreen><\/iframe><\/p>\n<h3>\u7f16\u5199\u9ad8\u6548\u7684 handler<\/h3>\n<p>\u5728\u4f7f\u7528 <strong>Proxy<\/strong> \u5bf9\u8c61\u65f6\uff0c\u7f16\u5199\u9ad8\u6548\u7684 handler \u662f\u5b9e\u73b0\u9ad8\u6027\u80fd\u6570\u636e\u64cd\u4f5c\u7684\u5173\u952e\u3002<strong>Proxy<\/strong> \u63d0\u4f9b\u4e86\u591a\u79cd\u62e6\u622a\u65b9\u6cd5\uff0c\u5982 <strong>get<\/strong>\u3001<strong>set<\/strong>\u3001<strong>deleteProperty<\/strong> \u7b49\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u8fdb\u884c\u589e\u5f3a\uff0c\u786e\u4fdd\u5728\u62e6\u622a\u64cd\u4f5c\u65f6\u6700\u5c0f\u5316\u6027\u80fd\u635f\u5931\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5f53\u68c0\u7d22\u548c\u8bbe\u7f6e\u5c5e\u6027\u65f6\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5229\u7528 <strong>get<\/strong> \u548c <strong>set<\/strong> \u65b9\u6cd5\u6765\u68c0\u67e5\u5c5e\u6027\u7684\u5408\u6cd5\u6027\uff0c\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u8d44\u6e90\u6d6a\u8d39\u3002\u4f8b\u5982\uff0c\u5982\u679c\u901a\u8fc7 <strong>set<\/strong> \u65b9\u6cd5\u963b\u6b62\u67d0\u4e9b\u65e0\u7528\u7684\u4fee\u6539\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6709\u6548\u63d0\u5347\u7a0b\u5e8f\u7684\u8fd0\u884c\u6548\u7387\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u5408\u7406\u5229\u7528 <strong>Reflect<\/strong> API \u53ef\u4ee5\u5e2e\u52a9\u7b80\u5316 handler \u8fc7\u7a0b\u3002\u8fd9\u4e2a API \u63d0\u4f9b\u4e86\u4e00\u7ec4\u9759\u6001\u65b9\u6cd5\uff0c\u5728 handler \u4e2d\u8c03\u7528 <strong>Reflect<\/strong> \u65b9\u6cd5\u6765\u8f6c\u53d1\u539f\u59cb\u64cd\u4f5c\uff0c\u4f7f\u4ee3\u7801\u6613\u4e8e\u7ef4\u62a4\u4e14\u6027\u80fd\u53ef\u9760\u3002<\/p>\n<h3>\u4f7f\u7528 Proxy \u8fdb\u884c\u6570\u636e\u9a8c\u8bc1<\/h3>\n<p><strong>Proxy<\/strong> \u4e0d\u4ec5\u80fd\u591f\u62e6\u622a\u548c\u76d1\u63a7\u5bf9\u8c61\u7684\u64cd\u4f5c\uff0c\u8fd8\u53ef\u4ee5\u7528\u4e8e\u6570\u636e\u9a8c\u8bc1\u3002\u8fd9\u4f7f\u5f97\u5f00\u53d1\u8005\u5728\u5904\u7406\u7528\u6237\u8f93\u5165\u6570\u636e\u65f6\u80fd\u591f\u66f4\u597d\u5730\u786e\u4fdd\u6570\u636e\u7684\u6709\u6548\u6027\u3002\u901a\u8fc7\u81ea\u5b9a\u4e49\u4ee3\u7406\u7684 <strong>set<\/strong> \u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u80fd\u591f\u5b9e\u73b0\u590d\u6742\u7684\u9a8c\u8bc1\u903b\u8f91\uff0c\u5e76\u5728\u65e0\u6548\u6570\u636e\u8f93\u5165\u65f6\u5408\u7406\u54cd\u5e94\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u8bbe\u7f6e\u5c5e\u6027\u65f6\u68c0\u67e5\u6570\u636e\u7c7b\u578b\uff0c\u5982\u679c\u8f93\u5165\u6570\u636e\u4e0d\u7b26\u5408\u9884\u671f\u7684\u6570\u636e\u7ed3\u6784\uff0c<strong>set<\/strong> \u65b9\u6cd5\u53ef\u4ee5\u629b\u51fa\u9519\u8bef\u6216\u65e5\u5fd7\u8bb0\u5f55\uff0c\u8fdb\u800c\u7ef4\u62a4\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002\u8fd9\u6837\uff0cProxy \u4ee3\u7406\u4fbf\u5728\u6570\u636e\u6d41\u8f6c\u65f6\u5145\u5f53\u4e86\u4e00\u4e2a\u9a8c\u8bc1\u7ba1\u7406\u5c42\uff0c\u6709\u6548\u907f\u514d\u4e86\u6f5c\u5728\u7684\u5e94\u7528\u7a0b\u5e8f\u9519\u8bef\u3002<\/p>\n<p>\u603b\u4e4b\uff0c\u901a\u8fc7\u8fd9\u4e00\u673a\u5236\uff0c\u5f00\u53d1\u8005\u83b7\u5f97\u4e86\u66f4\u5927\u7684\u7075\u6d3b\u6027\u548c\u53ef\u63a7\u6027\uff0c\u800c\u4e0d\u5fc5\u4f9d\u8d56\u4e8e\u5e94\u7528\u7a0b\u5e8f\u5185\u90e8\u7684\u5176\u4ed6\u9a8c\u8bc1\u903b\u8f91\uff0c\u4ece\u800c\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\u3002<\/p>\n<h3>\u5229\u7528 Proxy \u5b9e\u73b0\u89c2\u5bdf\u8005\u6a21\u5f0f<\/h3>\n<p>\u89c2\u5bdf\u8005\u6a21\u5f0f\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u7528\u4e8e\u5904\u7406\u5bf9\u8c61\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u800c\u4f7f\u7528 <strong>Proxy<\/strong> \u4ee3\u7406\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u5b9e\u73b0\u8fd9\u4e00\u6a21\u5f0f\u3002\u901a\u8fc7\u5728 handler \u4e2d\u5b9e\u73b0\u76f8\u5e94\u7684\u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u76ee\u6807\u5bf9\u8c61\u7684\u72b6\u6001\u53d8\u5316\u65f6\uff0c\u89e6\u53d1\u76f8\u5e94\u7684\u89c2\u5bdf\u8005\u8fdb\u884c\u6ce8\u518c\u6216\u6ce8\u9500\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528 <strong>get<\/strong> \u62e6\u622a\u65b9\u6cd5\uff0c\u5728\u8bbf\u95ee\u5c5e\u6027\u65f6\u6267\u884c\u56de\u8c03\uff0c\u6210\u4e3a\u4e00\u4e2a\u201c\u4e3b\u52a8\u201d\u89c2\u5bdf\u8005\u3002\u8fd9\u6837\uff0c\u5f53\u76ee\u6807\u5bf9\u8c61\u4e2d\u7684\u67d0\u4e2a\u5c5e\u6027\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7\u89e6\u53d1\u56de\u8c03\uff0c\u8ba9\u89c2\u5bdf\u8005\u5b9e\u65f6\u6536\u5230\u901a\u77e5\uff0c\u4ece\u800c\u505a\u51fa\u54cd\u5e94\u3002\u8fd9\u79cd\u6a21\u5f0f\u7684\u5b9e\u73b0\u65b9\u5f0f\u5927\u5927\u51cf\u5c11\u4e86\u8026\u5408\u5ea6\uff0c\u4f7f\u5f97\u5e94\u7528\u7a0b\u5e8f\u80fd\u591f\u7075\u6d3b\u5e94\u5bf9\u53d8\u5316\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u7ed3\u5408\u5176\u4ed6\u8bbe\u8ba1\u6a21\u5f0f\u5982\u53d1\u5e03-\u8ba2\u9605\u6a21\u5f0f\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5229\u7528 <strong>Proxy<\/strong> \u4ee3\u7406\u4e3a\u7ec4\u4ef6\u4e4b\u95f4\u7684\u901a\u4fe1\u63d0\u4f9b\u66f4\u9ad8\u5c42\u6b21\u7684\u652f\u6301\uff0c\u589e\u5f3a\u4e86\u4ee3\u7801\u7684\u6a21\u5757\u5316\u548c\u53ef\u6269\u5c55\u6027\u3002<\/p>\n<h3>\u5982\u4f55\u901a\u8fc7 Proxy \u5b9e\u73b0\u79c1\u6709\u5c5e\u6027<\/h3>\n<p>\u79c1\u6709\u5c5e\u6027\u7684\u7ba1\u7406\u662f\u5bf9\u8c61\u5bfc\u5411\u7f16\u7a0b\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u65b9\u9762\uff0c\u800c\u4f7f\u7528 <strong>Proxy<\/strong> \u4ee3\u7406\u53ef\u4ee5\u6709\u6548\u9690\u85cf\u5bf9\u8c61\u7684\u5185\u90e8\u72b6\u6001\u3002\u901a\u8fc7\u4f7f\u7528 <strong>WeakMap<\/strong> \u6765\u5b58\u50a8\u79c1\u6709\u5c5e\u6027\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u521b\u5efa\u5bf9\u5916\u4e0d\u53ef\u89c1\u7684\u5c5e\u6027\uff0c\u8fd9\u6837\u53ef\u4ee5\u66f4\u597d\u5730\u5b9e\u73b0\u6570\u636e\u5c01\u88c5\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u901a\u8fc7\u5728 <strong>get<\/strong> \u548c <strong>set<\/strong> \u65b9\u6cd5\u4e2d\u5305\u88c5\u5bf9 <strong>WeakMap<\/strong> \u7684\u8bbf\u95ee\uff0c\u5f00\u53d1\u8005\u4e0d\u4ec5\u53ef\u4ee5\u4fdd\u62a4\u5bf9\u8c61\u7684\u79c1\u6709\u6570\u636e\uff0c\u8fd8\u80fd\u591f\u5728\u4e0d\u66b4\u9732\u79c1\u6709\u5c5e\u6027\u7684\u60c5\u51b5\u4e0b\u63d0\u4f9b\u516c\u5171\u63a5\u53e3\uff0c\u4f9b\u5176\u4ed6\u7ec4\u4ef6\u8c03\u7528\u3002<\/p>\n<p>\u8fd9\u6837\uff0c\u4e0d\u4ec5\u5b9e\u73b0\u4e86\u79c1\u6709\u5c5e\u6027\u7684\u771f\u6b63\u9694\u79bb\uff0c\u540c\u65f6\u5728\u6a21\u5757\u5316\u8bbe\u8ba1\u4e2d\u4e5f\u80fd\u786e\u4fdd\u5185\u90e8\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u7a33\u5b9a\u6027\uff0c\u5927\u5927\u63d0\u9ad8\u4e86\u6574\u4f53\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002<\/p>\n<h2>\u5728\u9879\u76ee\u4e2d\u5b9e\u9645\u5e94\u7528 Proxy<\/h2>\n<p><iframe style=\"aspect-ratio: 16 \/ 9; width: 100%\" src=\"https:\/\/www.youtube.com\/embed\/4feR5QM5Mhs\" title=\"4feR5QM5Mhs\" frameBorder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowFullScreen><\/iframe><\/p>\n<h3>\u4f7f\u7528 Proxy \u4f18\u5316\u6027\u80fd<\/h3>\n<p>\u5728JavaScript\u4e2d\uff0c<strong>Proxy<\/strong>\u662f\u4e00\u79cd\u91cd\u8981\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5728\u9879\u76ee\u4e2d\u8fdb\u884c\u9ad8\u6548\u7684\u6027\u80fd\u4f18\u5316\u3002\u5229\u7528<strong>Proxy<\/strong>\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u62e6\u622a\u5e76\u91cd\u65b0\u5b9a\u4e49\u5bf9\u7279\u5b9a\u5bf9\u8c61\u7684\u57fa\u672c\u64cd\u4f5c\uff08\u5982\u5c5e\u6027\u67e5\u627e\u3001\u8d4b\u503c\u3001\u679a\u4e3e\u3001\u51fd\u6570\u8c03\u7528\u7b49\uff09\u3002\u8fd9\u4e00\u7279\u6027\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u591f\u5728\u4e0d\u6539\u53d8\u539f\u59cb\u5bf9\u8c61\u7684\u65b9\u6cd5\u4e0b\uff0c\u6dfb\u52a0\u989d\u5916\u7684\u903b\u8f91\uff0c\u4ece\u800c\u63d0\u5347\u6027\u80fd\u3002\u4f8b\u5982\uff0c\u5728\u6570\u636e\u5bc6\u96c6\u578b\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u901a\u8fc7\u4e3a\u6570\u636e\u7ed1\u5b9a\u5efa\u7acb<strong>Proxy<\/strong>\uff0c\u53ef\u4ee5\u5b9e\u65f6\u66f4\u65b0\u754c\u9762\u800c\u4e0d\u9700\u8981\u91cd\u590d\u6e32\u67d3\uff0c\u4ece\u800c\u8282\u7701\u4e86CPU\u548c\u5185\u5b58\u7684\u6d88\u8017\u3002<\/p>\n<p>\u501f\u52a9<strong>Proxy<\/strong>\u7684\u529f\u80fd\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u521b\u5efa\u9ad8\u5ea6\u54cd\u5e94\u7684\u7528\u6237\u754c\u9762\uff0c\u5e76\u5b9e\u73b0\u66f4\u6d41\u7545\u7684\u7528\u6237\u4f53\u9a8c\u3002\u901a\u8fc7\u5c06\u6570\u636e\u8bbf\u95ee\u7684\u903b\u8f91\u5c01\u88c5\u5728\u4ee3\u7406\u4e2d\uff0c\u5e76\u5b9e\u73b0\u7f13\u5b58\u673a\u5236\uff0c\u80fd\u591f\u663e\u8457\u51cf\u5c11\u5bf9\u4e8e\u670d\u52a1\u5668\u7684\u8bf7\u6c42\u9891\u7387\uff0c\u8fdb\u800c\u63d0\u5347\u6570\u636e\u52a0\u8f7d\u901f\u5ea6\u3002<\/p>\n<h3>\u5728\u5927\u578b\u9879\u76ee\u4e2d\u7ba1\u7406 state<\/h3>\n<p>\u5728\u73b0\u4ee3\u7684\u5355\u9875\u5e94\u7528\uff08SPA\uff09\u4e2d\uff0c\u72b6\u6001\u7ba1\u7406\u6781\u4e3a\u91cd\u8981\u3002\u5927\u578b\u9879\u76ee\u901a\u5e38\u6d89\u53ca\u5230\u590d\u6742\u7684\u72b6\u6001\u53d8\u5316\uff0c\u800c\u4f7f\u7528<strong>Proxy<\/strong>\u53ef\u4ee5\u8ba9\u72b6\u6001\u7ba1\u7406\u53d8\u5f97\u66f4\u52a0\u7b80\u5316\u548c\u9ad8\u6548\u3002\u5f00\u53d1\u8005\u80fd\u591f\u901a\u8fc7\u4ee3\u7406\u5bf9\u8c61\u6765\u76d1\u63a7\u72b6\u6001\u53d8\u5316\uff0c\u5f53\u72b6\u6001\u88ab\u66f4\u6539\u65f6\uff0c\u4ee3\u7406\u53ef\u4ee5\u81ea\u52a8\u89e6\u53d1\u5bf9\u5e94\u7684\u66f4\u65b0\u64cd\u4f5c\uff0c\u800c\u65e0\u9700\u660e\u786e\u5730\u8c03\u7528\u66f4\u65b0\u51fd\u6570\uff0c\u4ece\u800c\u63d0\u9ad8\u5f00\u53d1\u7684\u7075\u6d3b\u6027\u3002<\/p>\n<p>\u4f7f\u7528<strong>Proxy<\/strong>\u6765\u7ba1\u7406\u72b6\u6001\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\uff0c\u4e5f\u51cf\u5c11\u4e86\u72b6\u6001\u7ba1\u7406\u51fa\u73b0\u9519\u8bef\u7684\u53ef\u80fd\u6027\u3002\u5bf9\u4e8e\u62e5\u6709\u591a\u4e2a\u5d4c\u5957\u72b6\u6001\u7684\u5e94\u7528\uff0c<strong>Proxy<\/strong>\u80fd\u591f\u8f7b\u677e\u5e94\u5bf9\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u65e0\u9700\u62c5\u5fc3\u6df1\u5ea6\u590d\u5236\u548c\u72b6\u6001\u540c\u6b65\u7684\u95ee\u9898\u3002<\/p>\n<h3>\u914d\u5408\u5176\u4ed6 JavaScript \u5de5\u5177\u4f7f\u7528<\/h3>\n<p>\u5f53\u4e0e\u5176\u4ed6JavaScript\u5e93\u6216\u6846\u67b6\u7ed3\u5408\u4f7f\u7528\u65f6\uff0c<strong>Proxy<\/strong>\u7684\u4f5c\u7528\u66f4\u4e3a\u663e\u8457\u3002\u4f8b\u5982\uff0c\u7ed3\u5408<strong>Vue.js<\/strong>\u7684\u54cd\u5e94\u5f0f\u67b6\u6784\uff0c\u4f7f\u7528<strong>Proxy<\/strong>\u53ef\u4ee5\u4f7f\u5f97\u6570\u636e\u548c\u89c6\u56fe\u4e4b\u95f4\u7684\u540c\u6b65\u5de5\u4f5c\u53d8\u5f97\u66f4\u52a0\u8f7b\u677e\u3002\u6b64\u5916\uff0c\u4f7f\u7528<strong>Proxy<\/strong>\u65f6\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u501f\u52a9\u5de5\u5177\u5982<strong>Redux<\/strong>\u6765\u589e\u5f3a\u72b6\u6001\u7ba1\u7406\u7684\u529f\u80fd\uff0c\u4f7f\u5f97\u5168\u5c40\u72b6\u6001\u8c03\u5ea6\u66f4\u52a0\u9ad8\u6548\u3002<\/p>\n<p>\u901a\u8fc7\u4e0e\u5de5\u5177\u7684\u7ed3\u5408\uff0c<strong>Proxy<\/strong>\u80fd\u591f\u63d0\u5347\u6570\u636e\u5904\u7406\u7684\u6027\u80fd\uff0c\u4f18\u5316\u5e94\u7528\u7684\u54cd\u5e94\u901f\u5ea6\uff0c\u786e\u4fdd\u7528\u6237\u754c\u9762\u5728\u9ad8\u8d1f\u8f7d\u8fc7\u7a0b\u4e2d\u4f9d\u7136\u4fdd\u6301\u6d41\u7545\u3002<\/p>\n<h3>\u5b9e\u6218\u9879\u76ee\u6848\u4f8b\u5206\u4eab<\/h3>\n<p>\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u6709\u8bb8\u591a\u6210\u529f\u7684\u6848\u4f8b\u8bc1\u660e\u4e86<strong>Proxy<\/strong>\u7684\u6709\u6548\u6027\u3002\u4f8b\u5982\uff0c\u67d0\u7535\u5b50\u5546\u52a1\u7f51\u7ad9\u5728\u5176\u8d2d\u7269\u8f66\u7ba1\u7406\u6a21\u5757\u4e2d\u4f7f\u7528<strong>Proxy<\/strong>\u6765\u8ddf\u8e2a\u7528\u6237\u7684\u8d2d\u7269\u6570\u636e\u3002\u6bcf\u5f53\u7528\u6237\u6dfb\u52a0\u6216\u5220\u9664\u5546\u54c1\u65f6\uff0c\u4ee3\u7406\u4f1a\u81ea\u52a8\u66f4\u65b0\u8d2d\u7269\u8f66\u7684\u72b6\u6001\uff0c\u5e76\u5b9e\u65f6\u5c55\u793a\u7ed9\u7528\u6237\uff0c\u4ece\u800c\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u4f7f\u7528<strong>Proxy<\/strong>\u76d1\u63a7\u5e94\u7528\u7a0b\u5e8f\u7684\u7f51\u7edc\u8bf7\u6c42\uff0c\u53ef\u4ee5\u5728\u6570\u636e\u5904\u7406\u524d\u8fdb\u884c\u4e00\u4e9b\u989d\u5916\u7684\u9a8c\u8bc1\u548c\u8fc7\u6ee4\uff0c\u786e\u4fdd\u6570\u636e\u4f20\u8f93\u7684\u5b89\u5168\u4e0e\u9690\u79c1\u4fdd\u62a4\u3002\u8fd9\u79cd\u521b\u65b0\u7684\u8fd0\u7528\u4e0d\u4ec5\u63d0\u5347\u4e86\u5e94\u7528\u7684\u5b89\u5168\u6027\uff0c\u4e5f\u663e\u8457\u4f18\u5316\u4e86\u6570\u636e\u7ba1\u7406\u6d41\u7a0b\u3002<\/p>\n<h2>\u811a\u624b\u67b6\u5de5\u5177\u4e0e Proxy \u7684\u7ed3\u5408\u4f7f\u7528<\/h2>\n<p><iframe style=\"aspect-ratio: 16 \/ 9; width: 100%\" src=\"https:\/\/www.youtube.com\/embed\/M9WSBl5FJwE\" title=\"M9WSBl5FJwE\" frameBorder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowFullScreen><\/iframe><\/p>\n<h3>\u4f7f\u7528 Proxy \u6539\u5584\u5f00\u53d1\u4f53\u9a8c<\/h3>\n<p>\u5728\u73b0\u4ee3\u524d\u7aef\u5f00\u53d1\u4e2d\uff0c<strong>Proxy<\/strong> \u4f5c\u4e3a\u4e00\u79cd\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u53ef\u4ee5\u6781\u5927\u5730\u6539\u5584\u5f00\u53d1\u4f53\u9a8c\u3002\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u5728\u8fd0\u884c\u65f6\u62e6\u622a\u548c\u4fee\u6539\u5bf9\u5bf9\u8c61\u7684\u57fa\u672c\u64cd\u4f5c\uff0c\u5982\u5c5e\u6027\u67e5\u627e\u3001\u8d4b\u503c\u3001\u679a\u4e3e\u548c\u51fd\u6570\u8c03\u7528\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c<strong>Proxy<\/strong> \u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u65b9\u5f0f\u6765\u64cd\u4f5c\u6570\u636e\uff0c\u4ece\u800c\u7b80\u5316\u4e86\u72b6\u6001\u7ba1\u7406\u548c\u6570\u636e\u7ed1\u5b9a\uff0c\u66f4\u52a0\u7b26\u5408\u52a8\u6001\u7f16\u7a0b\u7684\u9700\u6c42\u3002<\/p>\n<p>\u5f00\u53d1\u8005\u53ef\u4ee5\u5229\u7528 <strong>Proxy<\/strong> \u5b9e\u73b0\u6570\u636e\u590d\u5236\u3001\u76d1\u63a7\u72b6\u6001\u53d8\u5316\u548c\u5b9e\u73b0\u61d2\u52a0\u8f7d\u7b49\u529f\u80fd\u3002\u4f8b\u5982\uff0c\u901a\u8fc7\u76d1\u542c\u5bf9\u8c61\u7684\u53d8\u5316\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u521b\u5efa\u66f4\u6709\u54cd\u5e94\u6027\u7684\u7528\u6237\u754c\u9762\uff0c\u8fd9\u5728\u6570\u636e\u9a71\u52a8\u7684\u5e94\u7528\u4e2d\u5c24\u5176\u91cd\u8981\u3002\u56e0\u6b64\uff0c<strong>Proxy<\/strong> \u4e0d\u4ec5\u5e2e\u52a9\u7b80\u5316\u4e86\u4ee3\u7801\uff0c\u540c\u65f6\u4e5f\u63d0\u9ad8\u4e86\u5e94\u7528\u7684\u6027\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<h3>\u5982\u4f55\u96c6\u6210 Proxy \u5230\u73b0\u6709\u6846\u67b6<\/h3>\n<p>\u5c06 <strong>Proxy<\/strong> \u96c6\u6210\u5230\u73b0\u6709\u7684\u524d\u7aef\u6846\u67b6\uff0c\u5982 Vue.js \u548c React\uff0c\u662f\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684\u8fc7\u7a0b\u3002\u5f00\u53d1\u8005\u53ea\u9700\u521b\u5efa\u4e00\u4e2a <strong>Proxy<\/strong> \u5b9e\u4f8b\uff0c\u7136\u540e\u901a\u8fc7\u5b83\u6765\u63a7\u5236\u5bf9\u72b6\u6001\u7684\u8bbf\u95ee\u548c\u4fee\u6539\u3002\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5b9e\u73b0\u66f4\u7075\u6d3b\u7684\u6570\u636e\u6d41\uff0c\u5e76\u6709\u6548\u7ba1\u7406\u7ec4\u4ef6\u4e4b\u95f4\u7684\u72b6\u6001\u4f20\u9012\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5728 Vue.js \u4e2d\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7 <strong>Proxy<\/strong> \u6765\u76d1\u63a7\u6570\u636e\u7684\u53d8\u5316\u5e76\u89e6\u53d1\u76f8\u5e94\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50\u3002\u8fd9\u79cd\u96c6\u6210\u5141\u8bb8\u5f00\u53d1\u8005\u5728\u4e0d\u727a\u7272\u6027\u80fd\u7684\u60c5\u51b5\u4e0b\uff0c\u6269\u5c55\u72b6\u6001\u7ba1\u7406\u89e3\u51b3\u65b9\u6848\u3002\u6b64\u5916\uff0c\u5728 React \u4e2d\uff0c\u53ef\u4ee5\u7ed3\u5408 <strong>Context API<\/strong> \u548c <strong>Proxy<\/strong> \u6765\u5b9e\u73b0\u5168\u5c40\u72b6\u6001\u7ba1\u7406\uff0c\u4f7f\u5f97\u7ec4\u4ef6\u4e4b\u95f4\u80fd\u591f\u9ad8\u6548\u5730\u5171\u4eab\u548c\u66f4\u65b0\u6570\u636e\u3002<\/p>\n<h3>\u4e0e Vue.js \u548c React \u7684\u7ed3\u5408<\/h3>\n<p>\u5728\u4e0e\u6846\u67b6\u7ed3\u5408\u65f6\uff0c<strong>Proxy<\/strong> \u80fd\u591f\u63d0\u4f9b\u5f3a\u5927\u7684\u529f\u80fd\u3002\u5bf9\u4e8e Vue.js\uff0c<strong>Proxy<\/strong> \u7684\u5e94\u7528\u4f7f\u5f97\u6570\u636e\u53cc\u5411\u7ed1\u5b9a\u66f4\u52a0\u9ad8\u6548\u3002\u7531\u4e8e <strong>Vue<\/strong> \u7684\u54cd\u5e94\u5f0f\u7cfb\u7edf\u5e95\u5c42\u4f9d\u8d56\u4e8e JavaScript \u7684 <strong>Proxy<\/strong>\uff0c\u5b83\u53ef\u4ee5\u5728\u53d8\u66f4\u6570\u636e\u65f6\u81ea\u52a8\u66f4\u65b0\u89c6\u56fe\uff0c\u4ece\u800c\u51cf\u5c11\u4e86\u5f00\u53d1\u8005\u5728\u8fdb\u884c\u6570\u636e\u7ed1\u5b9a\u65f6\u7684\u590d\u6742\u5ea6\u3002<\/p>\n<p>\u4e0e\u6b64\u540c\u65f6\uff0c\u5728 React \u6846\u67b6\u4e2d\uff0c<strong>Proxy<\/strong> \u7684\u7ed3\u5408\u4f7f\u5f97\u7ba1\u7406\u72b6\u6001\u66f4\u52a0\u7075\u6d3b\u3002\u7531\u4e8e React \u7684\u865a\u62df DOM \u66f4\u65b0\u673a\u5236\uff0c\u5229\u7528 <strong>Proxy<\/strong> \u8fdb\u884c\u72b6\u6001\u7ba1\u7406\u53ef\u4ee5\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u91cd\u65b0\u6e32\u67d3\uff0c\u63d0\u9ad8\u6027\u80fd\u3002\u56e0\u6b64\uff0c\u5f00\u53d1\u8005\u901a\u8fc7 <strong>Proxy<\/strong> \u6765\u4f18\u5316\u6027\u80fd\u7684\u540c\u65f6\uff0c\u4e5f\u589e\u5f3a\u4e86\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<h3>\u793a\u4f8b\u4ee3\u7801\u89e3\u6790<\/h3>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684 Vue.js \u7ec4\u4ef6\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528 <strong>Proxy<\/strong> \u6765\u7ba1\u7406\u7ec4\u4ef6\u72b6\u6001\uff1a<\/p>\n<pre><code>const state = new Proxy({ count: 0 }, {  \n  set(target, prop, value) {  \n    target[prop] = value;  \n    \/\/ \u89e6\u53d1\u89c6\u56fe\u66f4\u65b0\u6216\u5176\u4ed6\u903b\u8f91  \n    return true;  \n  }  \n});  \n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u5f00\u53d1\u8005\u521b\u5efa\u4e86\u4e00\u4e2a <strong>Proxy<\/strong> \u5b9e\u4f8b\u6765\u7ba1\u7406\u4e00\u4e2a\u7b80\u5355\u7684\u72b6\u6001\u5bf9\u8c61\u3002\u901a\u8fc7\u91cd\u5199 set \u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5728\u5c5e\u6027\u88ab\u66f4\u65b0\u65f6\u6267\u884c\u81ea\u5b9a\u4e49\u903b\u8f91\uff0c\u6bd4\u5982\u901a\u77e5\u89c6\u56fe\u66f4\u65b0\u3002\u8fd9\u79cd\u7075\u6d3b\u6027\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u591f\u66f4\u597d\u5730\u63a7\u5236\u5e94\u7528\u7684\u884c\u4e3a\uff0c\u63d0\u9ad8\u4e86\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<h2>JavaScript Proxy \u7684\u5b89\u5168\u8003\u91cf\u4e0e\u6ce8\u610f\u4e8b\u9879<\/h2>\n<h3>Proxy \u5e26\u6765\u7684\u5b89\u5168\u9690\u60a3<\/h3>\n<p>\u5728\u4f7f\u7528 <strong>Proxy<\/strong> \u7684\u8fc7\u7a0b\u4e2d\uff0c\u5f00\u53d1\u4eba\u5458\u9700\u8981\u8b66\u60d5\u6f5c\u5728\u7684\u5b89\u5168\u9690\u60a3\u3002Proxy \u7684\u4f7f\u7528\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6570\u636e\u88ab\u622a\u83b7\u6216\u8005\u7be1\u6539\uff0c\u5c24\u5176\u662f\u5728\u4f20\u8f93\u654f\u611f\u6570\u636e\u65f6\u3002\u5982\u679c\u6ca1\u6709\u5b9e\u65bd\u9002\u5f53\u7684\u5b89\u5168\u63a7\u5236\u63aa\u65bd\uff0c\u5982\u52a0\u5bc6\uff0c\u6076\u610f\u7528\u6237\u53ef\u80fd\u4f1a\u5229\u7528\u5f00\u653e\u7684 <strong>Proxy<\/strong> \u670d\u52a1\u5668\u8fdb\u884c\u653b\u51fb\uff0c\u5f71\u54cd\u7528\u6237\u6570\u636e\u7684\u9690\u79c1\u4e0e\u5b89\u5168\u3002<\/p>\n<p>\u6b64\u5916\uff0c<strong>Proxy<\/strong> \u53ef\u5bfc\u81f4\u5bf9\u7f51\u7edc\u6d41\u91cf\u7684\u6076\u610f\u76d1\u63a7\uff0c\u9020\u6210\u7528\u6237\u8bbf\u95ee\u6743\u9650\u7684\u6ee5\u7528\u3002\u4f8b\u5982\uff0c\u653b\u51fb\u8005\u53ef\u80fd\u4f1a\u83b7\u53d6\u7528\u6237\u7684\u8eab\u4efd\u4fe1\u606f\u6216\u5176\u4ed6\u654f\u611f\u6570\u636e\u3002\u5f00\u53d1\u4eba\u5458\u5728\u5b9e\u65bd <strong>Proxy<\/strong> \u65f6\uff0c\u5fc5\u987b\u4ed4\u7ec6\u8003\u8651\u5176\u7f51\u7edc\u73af\u5883\u4e2d\u7684\u5b89\u5168\u98ce\u9669\uff0c\u5e76\u91c7\u53d6\u5fc5\u8981\u7684\u9632\u62a4\u63aa\u65bd\uff0c\u786e\u4fdd\u6570\u636e\u4f20\u8f93\u7684\u5b89\u5168\u6027\u4e0e\u673a\u5bc6\u6027\u3002<\/p>\n<h3>\u5982\u4f55\u9632\u6b62\u6ee5\u7528 Proxy<\/h3>\n<p>\u4e3a\u4e86\u9632\u6b62 <strong>Proxy<\/strong> \u7684\u6ee5\u7528\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u91c7\u53d6\u591a\u79cd\u7b56\u7565\u3002\u9996\u5148\uff0c\u5e94\u5f53\u8bbe\u7f6e\u9002\u5f53\u7684\u8bbf\u95ee\u63a7\u5236\u9650\u5236\uff0c\u786e\u4fdd\u53ea\u6709\u7ecf\u8fc7\u6388\u6743\u7684\u7528\u6237\u624d\u80fd\u8bbf\u95ee <strong>Proxy<\/strong> \u670d\u52a1\u5668\u3002\u6b64\u5916\uff0c\u5229\u7528 <strong>VPN<\/strong> \u6280\u672f\u53ef\u4ee5\u5728\u7528\u6237\u548c <strong>Proxy<\/strong> \u4e4b\u95f4\u521b\u5efa\u5b89\u5168\u7684\u52a0\u5bc6\u901a\u9053\uff0c\u4ece\u800c\u964d\u4f4e\u6ee5\u7528\u7684\u98ce\u9669\u3002<\/p>\n<p>\u5176\u6b21\uff0c\u5b9a\u671f\u76d1\u63a7\u548c\u5ba1\u67e5\u7f51\u7edc\u6d41\u91cf\uff0c\u53ef\u4ee5\u5e2e\u52a9\u53ca\u65f6\u8bc6\u522b\u6f5c\u5728\u7684\u6ee5\u7528\u884c\u4e3a\u3002\u901a\u8fc7\u5b9e\u73b0\u81ea\u52a8\u65e5\u5fd7\u8bb0\u5f55\u4e0e\u5f02\u5e38\u68c0\u6d4b\uff0c\u6709\u52a9\u4e8e\u8fc5\u901f\u91c7\u53d6\u63aa\u65bd\uff0c\u4ee5\u9632\u6b62\u6ee5\u7528\u884c\u4e3a\u7684\u6269\u5c55\u3002<\/p>\n<h3>Proxy \u4e0e\u654f\u611f\u4fe1\u606f\u4fdd\u62a4<\/h3>\n<p>\u4f7f\u7528 <strong>Proxy<\/strong> \u65f6\uff0c\u5f00\u53d1\u4eba\u5458\u9700\u8981\u7279\u522b\u5173\u6ce8\u5982\u4f55\u6709\u6548\u4fdd\u62a4\u654f\u611f\u4fe1\u606f\u3002\u786e\u4fdd\u4f20\u8f93\u7684\u6570\u636e\u4f7f\u7528 HTTPS \u534f\u8bae\u975e\u5e38\u91cd\u8981\uff0c\u8fd9\u6837\u53ef\u4ee5\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u5bf9\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\uff0c\u786e\u4fdd\u5373\u4f7f\u6570\u636e\u5728 <strong>Proxy<\/strong> \u670d\u52a1\u5668\u4e0a\u88ab\u622a\u53d6\uff0c\u4e5f\u65e0\u6cd5\u88ab\u89e3\u5bc6\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u5b9a\u671f\u66f4\u65b0 <strong>Proxy<\/strong> \u670d\u52a1\u5668\u7684\u914d\u7f6e\uff0c\u79fb\u9664\u8fc7\u65f6\u7684\u4fe1\u606f\u53ca\u670d\u52a1\uff0c\u53ef\u4ee5\u51cf\u5c11\u654f\u611f\u4fe1\u606f\u6cc4\u9732\u7684\u98ce\u9669\u3002\u7ef4\u62a4\u826f\u597d\u7684 <strong>Proxy<\/strong> \u5b89\u5168\u6027\u64cd\u4f5c\u5c06\u80fd\u591f\u4e3a\u7528\u6237\u4fe1\u606f\u63d0\u4f9b\u66f4\u5927\u7684\u4fdd\u62a4\u3002<\/p>\n<h3>\u9519\u8bef\u5904\u7406\u7b56\u7565<\/h3>\n<p>\u5728\u5b9e\u65bd <strong>Proxy<\/strong> \u7684\u8fc7\u7a0b\u4e2d\uff0c\u5408\u7406\u7684\u9519\u8bef\u5904\u7406\u7b56\u7565\u540c\u6837\u91cd\u8981\u3002\u5236\u5b9a\u8be6\u7ec6\u7684\u9519\u8bef\u5904\u7406\u673a\u5236\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u5e94\u5bf9\u4e0d\u540c\u7c7b\u578b\u7684\u7f51\u7edc\u9519\u8bef\u4e0e\u5f02\u5e38\u60c5\u51b5\u3002\u4f8b\u5982\uff0c\u8bbe\u8ba1\u4f18\u96c5\u7684\u964d\u7ea7\u65b9\u6848\uff0c\u786e\u4fdd\u5728 <strong>Proxy<\/strong> \u670d\u52a1\u5668\u51fa\u73b0\u6545\u969c\u65f6\uff0c\u7528\u6237\u4ecd\u80fd\u4ee5\u67d0\u79cd\u65b9\u5f0f\u8bbf\u95ee\u8d44\u6e90\u800c\u4e0d\u81f3\u4e8e\u5f71\u54cd\u6574\u4f53\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<p>\u540c\u65f6\uff0c\u5408\u7406\u914d\u7f6e\u9519\u8bef\u65e5\u5fd7\u8bb0\u5f55\uff0c\u80fd\u591f\u4e3a\u540e\u7eed\u7684\u6545\u969c\u6392\u67e5\u63d0\u4f9b\u6709\u529b\u7684\u652f\u6301\u3002\u786e\u4fdd\u9519\u8bef\u4fe1\u606f\u4e0d\u4f1a\u66b4\u9732\u654f\u611f\u6570\u636e\u662f\u81f3\u5173\u91cd\u8981\u7684\uff0c\u8fd9\u6837\u53ef\u4ee5\u5728\u5904\u7406\u9519\u8bef\u65f6\u907f\u514d\u989d\u5916\u7684\u5b89\u5168\u98ce\u9669\u3002<\/p>\n<h2>\u5229\u7528 123Proxy \u670d\u52a1\u8fdb\u884c Proxy \u5b9e\u9a8c<\/h2>\n<h3>123Proxy \u63d0\u4f9b\u7684\u4f01\u4e1a\u7ea7\u670d\u52a1\u6982\u8ff0<\/h3>\n<p>\u5728\u5f53\u4eca\u4e92\u8054\u7f51\u73af\u5883\u4e2d\uff0c<strong>\u4ee3\u7406\u670d\u52a1\u5668<\/strong>\u7684\u4f7f\u7528\u6108\u53d1\u91cd\u8981\u3002<strong>123Proxy<\/strong> \u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u4f01\u4e1a\u7ea7 <strong>HTTP\u4ee3\u7406<\/strong> \u670d\u52a1\uff0c\u6db5\u76d6\u4e86\u591a\u79cd <strong>\u4ee3\u7406<\/strong> \u7c7b\u522b\u548c\u9700\u6c42\u573a\u666f\u3002\u8fd9\u4e9b\u670d\u52a1\u53ef\u4ee5\u6709\u6548\u63d0\u5347\u7528\u6237\u7684 <strong>\u9690\u79c1<\/strong> \u548c <strong>\u5b89\u5168\u6027<\/strong>\uff0c\u540c\u65f6\u589e\u5f3a\u7f51\u7edc\u7684\u6027\u80fd\u3002<\/p>\n<p>123Proxy \u7684\u670d\u52a1\u7c7b\u578b\u5305\u62ec\u6570\u636e\u4e2d\u5fc3 <strong>IPv4<\/strong> &#038; <strong>IPv6<\/strong>\u3001<strong>ISP\u4ee3\u7406<\/strong>\u3001<strong>\u4f4f\u5b85\u4ee3\u7406<\/strong> \u4ee5\u53ca\u65cb\u8f6c\u79fb\u52a8\u4ee3\u7406\u7b49\u3002\u901a\u8fc7\u8fd9\u4e9b\u4e0d\u540c\u7c7b\u578b\u7684\u4ee3\u7406\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u7279\u5b9a\u9700\u6c42\u8fdb\u884c\u9009\u62e9\uff0c\u4ee5\u5b9e\u73b0\u6700\u4f18\u7684 <strong>\u6570\u636e\u4f20\u8f93<\/strong> \u548c <strong>\u6d41\u91cf\u7ba1\u7406<\/strong> \u3002<\/p>\n<p>\u6b64\u5916\uff0c<strong>123Proxy<\/strong> \u8fd8\u652f\u6301 <strong>\u7f51\u9875\u5185\u5bb9\u8fc7\u6ee4<\/strong> \u548c <strong>\u7f13\u5b58<\/strong> \u7b49\u529f\u80fd\uff0c\u4f7f\u5f97\u5927\u91cf\u6570\u636e\u91c7\u96c6\u5de5\u4f5c\u53d8\u5f97\u9ad8\u6548\u800c\u987a\u7545\u3002\u8fd9\u5bf9\u4e8e\u9700\u8981\u8fdb\u884c\u9891\u7e41\u6570\u636e\u8bf7\u6c42\u7684\u6280\u672f\u4eba\u5458\u5c24\u4e3a\u91cd\u8981\u3002<\/p>\n<h3>\u5982\u4f55\u5728\u9879\u76ee\u4e2d\u96c6\u6210 123Proxy<\/h3>\n<p>\u5728\u9879\u76ee\u4e2d\u96c6\u6210<strong>123Proxy<\/strong> \u670d\u52a1\u7684\u6b65\u9aa4\u76f8\u5bf9\u7b80\u5355\u3002\u7528\u6237\u9996\u5148\u9700\u8981\u5728\u5176\u6d4f\u89c8\u5668\u4e2d\u914d\u7f6e\u4ee3\u7406\u8bbe\u7f6e\uff0c\u4ee5\u786e\u4fdd\u6240\u6709\u7684 <strong>\u5ba2\u6237\u7aef\u8bf7\u6c42<\/strong> \u90fd\u4f1a\u901a\u8fc7 <strong>Proxy<\/strong> \u670d\u52a1\u5668\u8f6c\u53d1\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u7528\u6237\u53ea\u9700\u5728\u6d4f\u89c8\u5668\u7684\u7f51\u7edc\u8bbe\u7f6e\u4e2d\uff0c\u8f93\u5165 <strong>123Proxy<\/strong> \u63d0\u4f9b\u7684\u670d\u52a1\u5668\u5730\u5740\u548c\u7aef\u53e3\u53f7\u3002\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u6240\u6709\u7684 HTTP \u548c HTTPS \u8bf7\u6c42\u5c06\u901a\u8fc7\u4ee3\u7406\u8fdb\u884c\uff0c\u63d0\u5347\u8bbf\u95ee\u7684\u5b89\u5168\u6027\u4e0e\u9690\u79c1\u3002<\/p>\n<p>\u901a\u8fc7 API\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u7075\u6d3b\u5730\u5b9e\u73b0\u96c6\u6210\u3002\u4ed6\u4eec\u53ef\u4ee5\u4f7f\u7528 SDK \u6216\u76f4\u63a5\u8c03\u7528 RESTful API \u8fdb\u884c <strong>\u8d1f\u8f7d\u5747\u8861<\/strong> \u548c\u6d41\u91cf\u8def\u7531\uff0c\u4fdd\u8bc1\u670d\u52a1\u8d28\u91cf\u3002<\/p>\n<h3>123Proxy \u5bf9\u6570\u636e\u91c7\u96c6\u7684\u652f\u6301<\/h3>\n<p>\u5bf9\u4e8e\u9700\u8981\u8fdb\u884c\u6570\u636e\u91c7\u96c6\u7684\u7528\u6237\u800c\u8a00\uff0c<strong>123Proxy<\/strong> \u7684\u670d\u52a1\u652f\u6301\u5c24\u4e3a\u5173\u952e\u3002\u5176\u63d0\u4f9b\u7684\u4ee3\u7406\u652f\u6301\u591a\u79cd\u534f\u8bae\uff0c\u65e2\u80fd\u5904\u7406 HTTP \u8bf7\u6c42\uff0c\u53c8\u652f\u6301 SOCKS5 \u534f\u8bae\uff0c\u786e\u4fdd <strong>\u6570\u636e\u9690\u79c1<\/strong> \u3002<\/p>\n<p>\u6b64\u5916\uff0c<strong>123Proxy<\/strong> \u7684\u4ee3\u7406\u670d\u52a1\u80fd\u591f\u6709\u6548\u5e94\u5bf9\u5927\u89c4\u6a21\u7684\u5e76\u53d1\u8bf7\u6c42\uff0c\u4ece\u800c\u4e3a\u6570\u636e\u91c7\u96c6\u8fc7\u7a0b\u4e2d\u7684\u98ce\u9669\u9632\u62a4\u63d0\u4f9b\u4e86\u826f\u597d\u7684\u89e3\u51b3\u65b9\u6848\u3002\u5176\u7f13\u5b58\u529f\u80fd\uff0c\u80fd\u591f\u663e\u8457\u63d0\u5347\u6570\u636e\u8bf7\u6c42\u7684\u54cd\u5e94\u901f\u5ea6\uff0c\u540c\u65f6\u51cf\u5c11\u5e26\u5bbd\u6d88\u8017\u3002<\/p>\n<p>\u5728\u8fdb\u884c\u6570\u636e\u91c7\u96c6\u65f6\uff0c<strong>123Proxy<\/strong> \u5141\u8bb8\u7528\u6237\u65e0\u9700\u62c5\u5fc3\u8bbf\u95ee\u9650\u5236\uff0c\u5168\u9762\u7a81\u7834\u5730\u57df\u9650\u5236\uff0c\u5b9e\u73b0\u81ea\u7531\u800c\u9ad8\u6548\u7684\u6570\u636e\u8bbf\u95ee\u3002<\/p>\n<h3>\u6848\u4f8b\u5206\u4eab\u4e0e\u6027\u80fd\u5206\u6790<\/h3>\n<p>\u501f\u52a9<strong>123Proxy<\/strong> \u7684\u670d\u52a1\uff0c\u6280\u672f\u56e2\u961f\u80fd\u591f\u5728\u591a\u4e2a\u9879\u76ee\u4e2d\u53d6\u5f97\u663e\u8457\u7684\u6210\u679c\u3002\u4f8b\u5982\uff0c\u4e00\u5bb6\u8de8\u5883\u7535\u5546\u4f01\u4e1a\u901a\u8fc7\u96c6\u6210<strong>123Proxy<\/strong>\uff0c\u6210\u529f\u5b9e\u73b0\u4e86\u9488\u5bf9\u7ade\u54c1\u7684\u5168\u9762\u6570\u636e\u91c7\u96c6\uff0c\u6709\u6548\u63d0\u5347\u4e86\u5e02\u573a\u7ade\u4e89\u529b\u3002<\/p>\n<p>\u5728\u6027\u80fd\u5206\u6790\u65b9\u9762\uff0c\u7ecf\u8fc7\u6d4b\u8bc4\uff0c\u4f7f\u7528<strong>123Proxy<\/strong>\u7684\u9879\u76ee\u52a0\u8f7d\u901f\u5ea6\u63d0\u5347\u4e8640%\u4ee5\u4e0a\uff0c\u540c\u65f6\u6570\u636e\u8bf7\u6c42\u7684\u6210\u529f\u7387\u4e5f\u5f97\u5230\u4e86\u663e\u8457\u6539\u5584\u3002\u8fd9\u8bc1\u660e\u4e86\u4f01\u4e1a\u7ea7\u4ee3\u7406\u670d\u52a1\u5bf9\u4e8e\u63d0\u5347 <strong>\u670d\u52a1\u5668\u4f18\u5316<\/strong> \u548c <strong>\u6d41\u91cf\u8def\u7531<\/strong> \u7684\u91cd\u8981\u6027\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u5229\u7528<strong>123Proxy<\/strong>\u7684\u4f01\u4e1a\u7ea7\u670d\u52a1\u8fdb\u884c <strong>Proxy<\/strong> \u5b9e\u9a8c\uff0c\u80fd\u591f\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u548c\u6280\u672f\u7231\u597d\u8005\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u83b7\u53d6\u66f4\u591a\u5b9e\u9645\u6548\u76ca\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u5728\u300aJavaScript \u4e2d\u7684 Proxy \u4ee3\u7406\uff1a\u6df1\u5165\u5b9e\u8df5\u4e0e\u6280\u5de7\u300b\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u5f00\u53d1\u4eba\u5458\u548c\u6280\u672f\u7231\u597d\u8005\u4eec\u4e86\u89e3\u5230<strong>Proxy \u4ee3\u7406<\/strong>\u7684\u57fa\u672c\u6982\u5ff5\u53ca\u5176\u5728\u73b0\u4eca\u7f16\u7801\u4e2d\u7684\u6838\u5fc3\u5e94\u7528\u3002\u901a\u8fc7\u5bf9Proxy\u6784\u9020\u51fd\u6570\u7684\u6df1\u5165\u8bb2\u89e3\u53ca\u5176\u4e0e\u666e\u901a\u5bf9\u8c61\u7684\u533a\u522b\uff0c\u8bfb\u8005\u4eec\u6e05\u6670\u5730\u638c\u63e1\u4e86\u5982\u4f55\u521b\u5efa<strong>\u6709\u6548\u7684\u4ee3\u7406<\/strong>\u5b9e\u4f8b\u53ca\u5176\u5e38\u89c1\u7684handler\u65b9\u6cd5\u3002\u6b64\u5916\uff0c\u6587\u7ae0\u4e5f\u63a2\u8ba8\u4e86Proxy\u5728\u6027\u80fd\u4f18\u5316\u3001\u6570\u636e\u9a8c\u8bc1\u548c\u72b6\u6001\u7ba1\u7406\u4e2d\u7684\u91cd\u8981\u6027\uff0c\u5c24\u5176\u5728\u5927\u578b\u9879\u76ee\u7684\u7ba1\u7406\u4e0a\u3002<\/p>\n<p>\u8fdb\u4e00\u6b65\u7684\uff0c\u4e86\u89e3Proxy\u7684trap\u65b9\u6cd5\uff0c\u4f8b\u5982get\u548cset\u7b49\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u5728\u4ee3\u7801\u4e2d\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u903b\u8f91\u4e0e\u529f\u80fd\uff0c\u540c\u65f6\u5e73\u8861<strong>\u9690\u79c1<\/strong>\u4e0e<strong>\u5b89\u5168<\/strong>\u6027\u3002\u5bf9\u4e8e\u654f\u611f\u4fe1\u606f\u4fdd\u62a4\uff0c\u8bfb\u8005\u4eec\u4e5f\u83b7\u5f97\u4e86\u6709\u4ef7\u503c\u7684\u5b89\u5168\u8003\u91cf\u4e0e\u6ce8\u610f\u4e8b\u9879\u3002\u5229\u7528123Proxy\u63d0\u4f9b\u7684\u670d\u52a1\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u5728\u81ea\u5df1\u7684\u9879\u76ee\u4e2d\u96c6\u6210\u9ad8\u6548\u7684<strong>\u4ee3\u7406\u670d\u52a1\u5668<\/strong>\uff0c\u8fdb\u884c\u6570\u636e\u91c7\u96c6\u4ee5\u6ee1\u8db3\u4f01\u4e1a\u7ea7\u9700\u6c42\u3002<\/p>\n<p>\u603b\u800c\u8a00\u4e4b\uff0cProxy\u4e0d\u4ec5\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u7f16\u7a0b\u5de5\u5177\uff0c\u4e5f\u4e3a\u6280\u672f\u7231\u597d\u8005\u63d0\u4f9b\u4e86\u65b0\u7684\u601d\u8def\u548c\u5b9e\u8df5\u6280\u5de7\uff0c\u4f7f\u5176\u80fd\u66f4\u597d\u5730\u5728\u8bbe\u8ba1\u6a21\u5f0f\u4e2d\u5e94\u7528\u8fd9\u4e00\u5de5\u5177\u3002<\/p>\n<h2>\u5e38\u89c1\u95ee\u9898\u89e3\u7b54<\/h2>\n<p><strong>Q: \u4ee3\u7406\u548cVPN\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/strong><\/p>\n<p><strong>A: <\/strong>\u4ee3\u7406\u5728\u5e94\u7528\u7a0b\u5e8f\u7ea7\u522b\u5de5\u4f5c\uff0c\u4ec5\u91cd\u65b0\u8def\u7531\u7279\u5b9a\u5e94\u7528\u7a0b\u5e8f\u6216\u6d4f\u89c8\u5668\u7684\u6d41\u91cf\uff0c\u800cVPN\u5728\u64cd\u4f5c\u7cfb\u7edf\u7ea7\u522b\u5de5\u4f5c\uff0c\u901a\u8fc7VPN\u670d\u52a1\u5668\u91cd\u65b0\u8def\u7531\u6240\u6709\u6d41\u91cf\u3002VPN\u901a\u5e38\u63d0\u4f9b\u66f4\u9ad8\u7684\u5b89\u5168\u6027\u548c\u9690\u79c1\u4fdd\u62a4\u3002<\/p>\n<p><strong>Q: \u5982\u4f55\u914d\u7f6e\u4e00\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\uff1f<\/strong><\/p>\n<p><strong>A: <\/strong>\u8981\u624b\u52a8\u8bbe\u7f6e\u4ee3\u7406\u670d\u52a1\u5668\u8fde\u63a5\uff0c\u7528\u6237\u53ef\u4ee5\u9009\u62e9\u201c\u5f00\u59cb\u201d\u6309\u94ae\uff0c\u7136\u540e\u4f9d\u6b21\u9009\u62e9\u201c\u8bbe\u7f6e\u201d>\u201c\u7f51\u7edc\u548cInternet\u201d>\u201c\u4ee3\u7406\u201d\uff0c\u5728\u624b\u52a8\u4ee3\u7406\u8bbe\u7f6e\u4e0b\uff0c\u6253\u5f00\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u5f00\u5173\uff0c\u5e76\u8f93\u5165\u4ee3\u7406IP\u5730\u5740\u53ca\u7aef\u53e3\u3002<\/p>\n<p><strong>Q: Windows\u5982\u4f55\u914d\u7f6e\u5168\u5c40\u4ee3\u7406\uff1f<\/strong><\/p>\n<p><strong>A: <\/strong>\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u5f00\u59cb\u83dc\u5355\u9009\u62e9\u8bbe\u7f6e\uff0c\u8fdb\u5165\u7f51\u7edc\u548cInternet\uff0c\u9009\u62e9\u4ee3\u7406\u9009\u9879\uff0c\u5173\u95ed\u81ea\u52a8\u68c0\u6d4b\u5f00\u5173\u540e\uff0c\u624b\u52a8\u8bbe\u7f6e\u4ee3\u7406\u3002<\/p>\n<p><strong>Q: \u4ec0\u4e48\u662fProxy\uff1f<\/strong><\/p>\n<p><strong>A: <\/strong>Proxy\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u7f51\u7edc\u670d\u52a1\uff0c\u5b83\u53ef\u4ee5\u7f13\u5b58\u548c\u8fc7\u6ee4\u5185\u5bb9\uff0c\u63d0\u5347\u8bbf\u95ee\u901f\u5ea6\u5e76\u4fdd\u62a4\u7528\u6237\u9690\u79c1\uff0c\u901a\u5e38\u88ab\u7528\u4f5c\u4e00\u4e2a\u4e2d\u95f4\u4eba\u6765\u4fc3\u8fdb\u53cc\u65b9\u901a\u4fe1\u3002<\/p>\n<p><strong>Q: JavaScript\u4e2d\u7684Proxy\u5bf9\u8c61\u662f\u5982\u4f55\u5de5\u4f5c\u7684\uff1f<\/strong><\/p>\n<p><strong>A: <\/strong>Proxy\u5bf9\u8c61\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\u7684\u4ee3\u7406\uff0c\u4ee5\u4fbf\u62e6\u622a\u548c\u81ea\u5b9a\u4e49\u57fa\u672c\u64cd\u4f5c\uff0c\u5982\u5c5e\u6027\u67e5\u627e\u3001\u8d4b\u503c\u548c\u51fd\u6570\u8c03\u7528\u3002\u5176\u5de5\u4f5c\u673a\u5236\u4e3b\u8981\u4f9d\u8d56\u4e8e\u4e00\u7cfb\u5217\u7684trap\u65b9\u6cd5\u3002<\/p>\n<p><strong>Q: \u4f55\u4e3aproxy trap\u65b9\u6cd5\uff1f<\/strong><\/p>\n<p><strong>A: <\/strong>trap\u65b9\u6cd5\u662fProxy\u63d0\u4f9b\u7684\u4e00\u79cd\u673a\u5236\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u5bf9\u8c61\u7684\u64cd\u4f5c\uff0c\u5305\u62ecget\u3001set\u3001apply\u7b49\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u7528\u4e8e\u63a7\u5236\u5bf9\u76ee\u6807\u5bf9\u8c61\u7684\u8bbf\u95ee\u548c\u64cd\u4f5c\u3002<\/p>\n<p><strong>Q: \u4f7f\u7528Proxy\u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\u7684\u597d\u5904\u662f\u4ec0\u4e48\uff1f<\/strong><\/p>\n<p><strong>A: <\/strong>\u4f7f\u7528Proxy\u8fdb\u884c\u6570\u636e\u9a8c\u8bc1\u53ef\u4ee5\u4f7f\u6570\u636e\u5904\u7406\u66f4\u52a0\u7075\u6d3b\u548c\u52a8\u6001\uff0c\u5728\u6570\u636e\u88ab\u4fee\u6539\u65f6\u53ca\u65f6\u8fdb\u884c\u9a8c\u8bc1\uff0c\u4ece\u800c\u786e\u4fdd\u6570\u636e\u7684\u4e00\u81f4\u6027\u548c\u5b89\u5168\u6027\u3002<\/p>\n<p><strong>Q: \u5728\u5927\u578b\u9879\u76ee\u4e2d\u5982\u4f55\u7ba1\u7406\u72b6\u6001\uff1f<\/strong><\/p>\n<p><strong>A: <\/strong>\u5728\u5927\u578b\u9879\u76ee\u4e2d\uff0c\u4f7f\u7528Proxy\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u597d\u5730\u7ba1\u7406\u5e94\u7528\u7684\u72b6\u6001\uff0c\u901a\u8fc7\u62e6\u622a\u548c\u76d1\u63a7\u5bf9\u72b6\u6001\u7684\u64cd\u4f5c\uff0c\u786e\u4fdd\u5e94\u7528\u6570\u636e\u7684\u900f\u660e\u548c\u4e00\u81f4\u6027\u3002<\/p>\n<h2>\u53c2\u8003\u6587\u732e<\/h2>\n<p>1 &#8211; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Proxy_server\">Wikipedia<\/a><br \/>2 &#8211; <a href=\"https:\/\/zh.wikipedia.org\/zh-hans\/%E4%BB%A3%E7%90%86%E6%9C%8D%E5%8A%A1%E5%99%A8\">\u7ef4\u57fa\u767e\u79d1<\/a><br \/>3 &#8211; <a href=\"https:\/\/proxy-seller.com\/zh\/\">Proxy-Seller<\/a><br \/>4 &#8211; <a href=\"https:\/\/www.ipburger.com\/zh\/blog\/what-is-configure-proxy\/\">IPBurger.com<\/a><br \/>5 &#8211; <a href=\"https:\/\/nordvpn.com\/zh\/blog\/vpn-proxy-qubie\/\">NordVPN<\/a><br \/>6 &#8211; <a href=\"https:\/\/123proxy.com\">123Proxy<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u662f\u5426\u66fe\u60f3\u8fc7\u5982\u4f55\u901a\u8fc7 JavaScript \u63d0\u5347\u5e94\u7528\u7684\u6027\u80fd\u4e0e\u5b89\u5168\uff1f\u5728\u73b0\u4ee3\u7f51\u7edc\u4ee3\u7406\u7684\u4e16\u754c\u4e2d\uff0cProxy \u4ee3\u7406\u6210\u4e3a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":15827,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-15847","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/posts\/15847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/comments?post=15847"}],"version-history":[{"count":0,"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/posts\/15847\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/media\/15827"}],"wp:attachment":[{"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/media?parent=15847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/categories?post=15847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/123proxy.cn\/blogs\/wp-json\/wp\/v2\/tags?post=15847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}