{"id":566,"date":"2025-12-07T09:40:50","date_gmt":"2025-12-07T01:40:50","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=566"},"modified":"2025-12-07T09:40:50","modified_gmt":"2025-12-07T01:40:50","slug":"javascript%e5%89%8d%e7%ab%af%e9%a1%b5%e9%9d%a2%e7%99%bd%e5%b1%8f%e9%97%ae%e9%a2%98%e6%8e%92%e6%9f%a5%e4%b8%8e%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/12\/07\/javascript%e5%89%8d%e7%ab%af%e9%a1%b5%e9%9d%a2%e7%99%bd%e5%b1%8f%e9%97%ae%e9%a2%98%e6%8e%92%e6%9f%a5%e4%b8%8e%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88\/","title":{"rendered":"JavaScript\u524d\u7aef\u9875\u9762\u767d\u5c4f\u95ee\u9898\u6392\u67e5\u4e0e\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"\n<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd\u8d85\u5b9e\u7528\u3001\u53ef\u76f4\u63a5\u7528\u5728\u9879\u76ee\u91cc\u7684 <strong>\u300aJavaScript \u524d\u7aef\u9875\u9762\u767d\u5c4f\u95ee\u9898\u6392\u67e5\u4e0e\u89e3\u51b3\u65b9\u6848\u300b<\/strong>\uff0c\u7ed3\u6784\u6e05\u6670\u3001\u6b65\u9aa4\u660e\u786e\uff0c\u9002\u5408\u5b9e\u6218\u6392\u67e5\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>JavaScript \u524d\u7aef\u9875\u9762\u767d\u5c4f\u95ee\u9898\u6392\u67e5\u4e0e\u89e3\u51b3\u65b9\u6848\uff08\u5b8c\u6574\u7248\uff09<\/strong><\/h1>\n\n\n\n<p>\u5f53\u4f60\u8bbf\u95ee\u524d\u7aef\u9875\u9762\u65f6\uff0c\u51fa\u73b0 <strong>\u5b8c\u5168\u7a7a\u767d\u3001\u65e0\u62a5\u9519\u6216\u65e0\u6cd5\u52a0\u8f7d\u5185\u5bb9<\/strong>\u2014\u2014\u8fd9\u5c31\u662f\u5178\u578b\u7684\u300c\u767d\u5c4f\u95ee\u9898\u300d\u3002\u767d\u5c4f\u53ef\u80fd\u6765\u81ea\u6784\u5efa\u3001\u8d44\u6e90\u52a0\u8f7d\u3001\u8fd0\u884c\u65f6 JS \u62a5\u9519\u3001\u7f51\u7edc\u3001\u8de8\u57df\u3001\u7f13\u5b58\u7b49\u591a\u79cd\u539f\u56e0\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u4ece <strong>\u5e38\u89c1\u539f\u56e0 \u2192 \u6392\u67e5\u6b65\u9aa4 \u2192 \u89e3\u51b3\u65b9\u6848<\/strong> \u5e26\u4f60\u5feb\u901f\u5b9a\u4f4d\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 <strong>\u4e00\u3001\u767d\u5c4f\u5e38\u89c1\u539f\u56e0\u603b\u89c8<\/strong><\/h1>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7c7b\u578b<\/th><th>\u5178\u578b\u539f\u56e0<\/th><\/tr><\/thead><tbody><tr><td><strong>\u6784\u5efa\/\u6253\u5305\u95ee\u9898<\/strong><\/td><td>\u6253\u5305\u5931\u8d25\u3001\u8d44\u6e90\u8def\u5f84\u9519\u8bef\u3001publicPath \u914d\u7f6e\u9519\u8bef\u3001\u6784\u5efa\u4ea7\u7269\u7f3a\u5931<\/td><\/tr><tr><td><strong>\u8def\u7531\u95ee\u9898<\/strong><\/td><td>History \u6a21\u5f0f\u672a\u505a\u597d Nginx \u914d\u7f6e\u3001404 \u91cd\u5b9a\u5411\u9519\u8bef\u3001\u52a8\u6001\u8def\u7531\u4e22\u5931<\/td><\/tr><tr><td><strong>JS \u8fd0\u884c\u65f6\u9519\u8bef<\/strong><\/td><td>\u4ee3\u7801\u62a5\u9519\u5bfc\u81f4 JS \u505c\u6b62\u6267\u884c\uff0c\u9875\u9762\u65e0\u6cd5\u6e32\u67d3<\/td><\/tr><tr><td><strong>\u8d44\u6e90\u52a0\u8f7d\u5931\u8d25<\/strong><\/td><td>JS\/CSS \u52a0\u8f7d 404\/403\u3001\u8de8\u57df\u5931\u8d25\u3001CDN \u5d29\u6e83<\/td><\/tr><tr><td><strong>\u73af\u5883\u53d8\u91cf\u9519\u8bef<\/strong><\/td><td>\u4f7f\u7528 <code>.env<\/code> \u4e2d\u672a\u5b9a\u4e49\u6216\u9519\u8bef\u53d8\u91cf\u5bfc\u81f4\u811a\u672c\u5f02\u5e38<\/td><\/tr><tr><td><strong>\u7f13\u5b58\u95ee\u9898<\/strong><\/td><td>\u8001\u7248\u672c\u8d44\u6e90\u88ab\u7f13\u5b58\u3001\u5f3a\u7f13\u5b58\u672a\u66f4\u65b0<\/td><\/tr><tr><td><strong>\u6d4f\u89c8\u5668\u517c\u5bb9\u6027<\/strong><\/td><td>Promise\u3001fetch\u3001forEach\u3001class \u65e0 polyfill \u5bfc\u81f4\u8001\u6d4f\u89c8\u5668\u6267\u884c\u5931\u8d25<\/td><\/tr><tr><td><strong>\u63a5\u53e3\u963b\u585e\u6e32\u67d3<\/strong><\/td><td>\u9996\u5c4f\u63a5\u53e3\u5361\u6b7b\u3001\u63a5\u53e3\u62a5\u9519\u5bfc\u81f4\u9875\u9762\u672a\u521d\u59cb\u5316<\/td><\/tr><tr><td><strong>\u5b89\u5168\u7b56\u7565<\/strong><\/td><td>Content-Security-Policy\u3001\u8de8\u57df\u3001cookie SameSite \u8bbe\u7f6e\u4e0d\u5f53<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udd0d <strong>\u4e8c\u3001\u6392\u67e5\u95ee\u9898\u7684\u5b8c\u6574\u6b65\u9aa4\uff08\u4ece\u6700\u7b80\u5355\u5230\u590d\u6742\uff09<\/strong><\/h1>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 1\uff1a\u6253\u5f00\u6d4f\u89c8\u5668 F12\uff0c\u770b Console \u662f\u5426\u6709\u7ea2\u8272\u62a5\u9519<\/strong><\/h2>\n\n\n\n<p>\u91cd\u70b9\u770b\u8fd9\u4e9b\u62a5\u9519\u7c7b\u578b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Uncaught TypeError: ...<\/code><\/li>\n\n\n\n<li><code>Cannot read property 'xxx' of undefined<\/code><\/li>\n\n\n\n<li><code>SyntaxError<\/code><\/li>\n\n\n\n<li><code>Unexpected token '&lt;'<\/code>\uff08JS \u88ab\u8fd4\u56de\u6210 HTML\uff09<\/li>\n\n\n\n<li><code>chunk-vendors.js 404<\/code><\/li>\n\n\n\n<li><code>Failed to load resource: the server responded with a status of 403\/404\/500<\/code><\/li>\n<\/ul>\n\n\n\n<p>\ud83d\udccc <strong>\u5982\u679c JS \u62a5\u9519\uff0c\u9875\u9762\u5c31\u65e0\u6cd5\u6267\u884c\uff0c\u5fc5\u767d\u5c4f\u3002<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 2\uff1a\u67e5\u770b Network\uff0c\u770b\u6838\u5fc3 js\/css \u662f\u5426\u52a0\u8f7d\u6210\u529f<\/strong><\/h2>\n\n\n\n<p>\u91cd\u70b9\u5173\u6ce8\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>app.js<\/code> \/ <code>chunk-vendors.js<\/code> \/ <code>main.js<\/code> \u662f\u5426 200\uff1f<\/li>\n\n\n\n<li>\u6709\u6ca1\u6709 404\uff1f<\/li>\n\n\n\n<li>\u6709\u6ca1\u6709\u8de8\u57df <code>CORS error<\/code>\uff1f<\/li>\n\n\n\n<li>\u662f\u5426\u8fd4\u56de HTML\uff1f\uff08\u88ab\u91cd\u5b9a\u5411\uff09<\/li>\n\n\n\n<li>\u4e0b\u8f7d\u662f\u5426\u5361\u4f4f pending\uff1f<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 3\uff1a\u68c0\u67e5 Vue\/React \u7b49\u524d\u7aef\u6846\u67b6\u662f\u5426\u6e32\u67d3\u6839\u8282\u70b9<\/strong><\/h2>\n\n\n\n<p>\u6bd4\u5982\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div id=&quot;app&quot;&gt;&amp;lt;\/div&gt;\n\n<\/pre><\/div>\n\n\n<p>\u82e5\u627e\u4e0d\u5230\u6839\u8282\u70b9\uff0c\u4f1a\u62a5\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;Vue warn]: Cannot find element: #app\n\n<\/pre><\/div>\n\n\n<p>\u6216\u8005\u5e94\u7528\u521d\u59cb\u5316\u5931\u8d25\uff0c\u4f1a\u76f4\u63a5\u767d\u5c4f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 4\uff1a\u786e\u5b9a\u8def\u7531\u662f\u5426\u5bfc\u81f4\u767d\u5c4f<\/strong><\/h2>\n\n\n\n<p><strong>History \u6a21\u5f0f\u6700\u5e38\u89c1\u95ee\u9898<\/strong>\uff1a<\/p>\n\n\n\n<p>\u8bbf\u95ee <code>\/abc<\/code> \u62a5 404\uff0c\u56e0\u4e3a\u540e\u7aef\u6ca1\u6709\u914d\u7f6e fallback\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u662f\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 Vue Router history \u6a21\u5f0f<\/h3>\n\n\n\n<p><strong>Nginx \u914d\u7f6e\u9700\u6dfb\u52a0\uff1a<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nlocation \/ {\n    try_files $uri $uri\/ \/index.html;\n}\n\n<\/pre><\/div>\n\n\n<p>\u5426\u5219\u5237\u65b0\u9875\u9762\u5c31\u767d\u5c4f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 5\uff1a\u68c0\u67e5\u6784\u5efa\u95ee\u9898\uff08publicPath \/ base \u914d\u7f6e\u9519\u8bef\uff09<\/strong><\/h2>\n\n\n\n<p>\u75c7\u72b6\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u672c\u5730\u6b63\u5e38\uff0c\u7ebf\u4e0a\u767d\u5c4f<\/li>\n\n\n\n<li>JS\/CSS \u8bf7\u6c42\u8def\u5f84\u4e3a\uff1a<code>\/static\/js\/app.js<\/code><br>\u4f46\u4f60\u7684\u7ad9\u70b9\u5b9e\u9645\u90e8\u7f72\u5728\uff1a<code>\/myapp\/<\/code> \u5b50\u8def\u5f84\u4e0b<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Vue CLI\uff1a<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nmodule.exports = {\n  publicPath: &#039;\/myapp\/&#039;\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Vite\uff1a<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nexport default defineConfig({\n  base: &#039;\/myapp\/&#039;\n})\n\n<\/pre><\/div>\n\n\n<p>\u5426\u5219\u8d44\u6e90 404 \u2192 \u767d\u5c4f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 6\uff1a\u68c0\u67e5\u73af\u5883\u53d8\u91cf .env \u662f\u5426\u8bef\u914d\u7f6e<\/strong><\/h2>\n\n\n\n<p>\u4f8b\u5982\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst api = process.env.VUE_APP_URL;\n\n<\/pre><\/div>\n\n\n<p>\u4f46 <code>.env.production<\/code> \u4e2d\u6ca1\u914d\u7f6e\uff0c\u6253\u5305\u540e\u4e3a <code>undefined<\/code> \u2192 \u8c03\u63a5\u53e3\u62a5\u9519 \u2192 \u521d\u59cb\u5316\u5931\u8d25 \u2192 \u767d\u5c4f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 7\uff1a\u6d4f\u89c8\u5668\u517c\u5bb9\u6027\u95ee\u9898<\/strong><\/h2>\n\n\n\n<p>\u7279\u522b\u662f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Promise<\/li>\n\n\n\n<li>fetch<\/li>\n\n\n\n<li>Array.find<\/li>\n\n\n\n<li>Object.assign<\/li>\n<\/ul>\n\n\n\n<p>\u5728 iOS 9\u3001Android 5 \u6d4f\u89c8\u5668\u4e0a\u53ef\u80fd\u76f4\u63a5\u62a5\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nObject doesn&#039;t support property or method &#039;find&#039;\n\n<\/pre><\/div>\n\n\n<p>\u2714 \u89e3\u51b3\uff1a\u6dfb\u52a0 polyfill \u6216\u4f7f\u7528 babel\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 8\uff1a\u68c0\u67e5 CSP\uff08Content Security Policy\uff09\u662f\u5426\u9650\u5236 JS \u52a0\u8f7d<\/strong><\/h2>\n\n\n\n<p>\u5f53\u670d\u52a1\u5668\u54cd\u5e94\u5934\u8bbe\u7f6e\u4e86\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nContent-Security-Policy: script-src &#039;self&#039;\n\n<\/pre><\/div>\n\n\n<p>\u4f46 JS \u6765\u81ea CDN\uff0c\u5c31\u4f1a\u88ab\u963b\u6b62\uff0c\u4e5f\u4f1a\u767d\u5c4f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 9\uff1a\u63a5\u53e3\u963b\u585e\u5bfc\u81f4\u767d\u5c4f<\/strong><\/h2>\n\n\n\n<p>\u5982\u679c\u4f60\u7684\u9996\u9875\u521d\u59cb\u5316\u5fc5\u987b\u8bf7\u6c42 API\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nawait getUserInfo();\n\n<\/pre><\/div>\n\n\n<p>\u63a5\u53e3\u8d85\u65f6\u6216\u5f02\u5e38\u5c31\u4f1a\u5361\u4f4f\u9996\u5c4f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\uddef <strong>\u4e09\u3001\u767d\u5c4f\u6700\u5e38\u89c1\u539f\u56e0\u4e0e\u89e3\u51b3\u65b9\u6848\uff08\u6309\u51fa\u73b0\u9891\u7387\u6392\u5e8f\uff09<\/strong><\/h1>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1. JS \u62a5\u9519\u5bfc\u81f4\u767d\u5c4f\uff08\u6982\u7387\u6700\u9ad8\uff09<\/strong><\/h2>\n\n\n\n<p>\u2714 <strong>\u770b Console \u62a5\u9519<\/strong><br>\u51fa\u73b0 <code>xxx is not a function<\/code>\u3001<code>undefined<\/code> \u7b49\u3002<\/p>\n\n\n\n<p>\u2714 \u89e3\u51b3\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u52a0 try\/catch<\/li>\n\n\n\n<li>\u4f18\u5316 API \u8fd4\u56de\u5224\u65ad<\/li>\n\n\n\n<li>\u52a0\u9632\u5fa1\u5f0f\u7f16\u7a0b<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2. \u8d44\u6e90\u52a0\u8f7d 404 \/ publicPath \u9519\u8bef<\/strong><\/h2>\n\n\n\n<p>\u8868\u73b0\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u672c\u5730\u6b63\u5e38\uff0c\u7ebf\u4e0a\u767d\u5c4f<\/li>\n\n\n\n<li>Network \u663e\u793a .js \u6587\u4ef6 404<\/li>\n<\/ul>\n\n\n\n<p>\u2714 \u8c03\u6574 Vue\/Vite \u6784\u5efa\u8def\u5f84\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3. History \u6a21\u5f0f\u8def\u7531 + Nginx \u672a\u914d\u7f6e fallback<\/strong><\/h2>\n\n\n\n<p>\u5237\u65b0\u9875\u9762\u767d\u5c4f\u3002<\/p>\n\n\n\n<p>\u2714 \u6dfb\u52a0\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ntry_files $uri $uri\/ \/index.html;\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. \u6253\u5305\u4ea7\u7269\u8fd4\u56de HTML \u5bfc\u81f4 <code>Unexpected token '&lt;'<\/code><\/strong><\/h2>\n\n\n\n<p>\u539f\u56e0\uff1a\u524d\u7aef\u8bbf\u95ee\u7684 js \u6587\u4ef6\u88ab\u540e\u7aef\u8def\u7531\u62e6\u622a\u5e76\u8fd4\u56de\u4e86 HTML\u3002<\/p>\n\n\n\n<p>\u2714 \u8ba9\u9759\u6001\u8d44\u6e90\u8def\u5f84\u7ed5\u8fc7\u540e\u7aef\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5. \u6d4f\u89c8\u5668\u517c\u5bb9\u6027\uff1a\u7f3a polyfill<\/strong><\/h2>\n\n\n\n<p>\u2714 \u4f7f\u7528\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnpm install @babel\/polyfill\n\n<\/pre><\/div>\n\n\n<p>\u6216\u8005 Vite \uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnpm i -D @vitejs\/plugin-legacy\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>6. \u7f13\u5b58\u95ee\u9898\uff08\u8bbf\u95ee\u65e7\u7248\u672c\u6b8b\u7559\u8d44\u6e90\uff09<\/strong><\/h2>\n\n\n\n<p>\u2714 \u89e3\u51b3\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6587\u4ef6\u540d\u52a0 hash<\/li>\n\n\n\n<li>nginx \u7981\u6b62\u5f3a\u7f13\u5b58\u65e7 HTML<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nlocation \/ {\n    add_header Cache-Control &quot;no-cache&quot;;\n}\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\uddf0 <strong>\u56db\u3001\u7ebf\u4e0a\u767d\u5c4f\u81ea\u52a8\u6355\u83b7\u4e0e\u4e0a\u62a5\uff08\u9ad8\u8d28\u91cf\u9879\u76ee\u5fc5\u5907\uff09<\/strong><\/h1>\n\n\n\n<p>\u52a0\u5165\u5168\u5c40\u9519\u8bef\u6355\u83b7\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nwindow.addEventListener(&#039;error&#039;, function (e) {\n  reportError(e);\n}, true);\n\nwindow.addEventListener(&#039;unhandledrejection&#039;, function (e) {\n  reportError(e.reason);\n});\n\n<\/pre><\/div>\n\n\n<p>\u653e\u5165\u76d1\u63a7\u7cfb\u7edf\uff08Sentry\u3001\u81ea\u5efa\u65e5\u5fd7\u5e73\u53f0\uff09\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u5b9a\u4f4d\u7528\u6237\u624b\u673a\u4e0a\u7684\u767d\u5c4f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd\u8d85\u5b9e\u7528\u3001\u53ef\u76f4\u63a5\u7528\u5728\u9879\u76ee\u91cc\u7684 \u300aJavaScript \u524d\u7aef\u9875\u9762\u767d\u5c4f\u95ee\u9898&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/12\/07\/javascript%e5%89%8d%e7%ab%af%e9%a1%b5%e9%9d%a2%e7%99%bd%e5%b1%8f%e9%97%ae%e9%a2%98%e6%8e%92%e6%9f%a5%e4%b8%8e%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-566","post","type-post","status-publish","format-standard","hentry","category-javascript"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=566"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/566\/revisions"}],"predecessor-version":[{"id":567,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/566\/revisions\/567"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}