{"id":110422,"date":"2026-09-28T16:40:46","date_gmt":"2026-09-28T08:40:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/110422.html"},"modified":"2026-09-28T16:40:46","modified_gmt":"2026-09-28T08:40:46","slug":"%e4%bb%8e%e6%99%ae%e9%80%9a-script-%e5%88%b0-esm%ef%bc%9a%e4%b8%80%e6%96%87%e6%90%9e%e6%87%82-javascript-%e6%a8%a1%e5%9d%97%e3%80%81iife-%e5%92%8c-window","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/110422.html","title":{"rendered":"\u4ece\u666e\u901a script \u5230 ESM\uff1a\u4e00\u6587\u641e\u61c2 JavaScript \u6a21\u5757\u3001IIFE \u548c window"},"content":{"rendered":"<p>        \/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/<br \/>\n        #content_views .toc,<br \/>\n        \/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/<br \/>\n        #content_views.markdown_views &gt; p:empty:has(+ .toc),<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty,<br \/>\n        \/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/<br \/>\n        #content_views.htmledit_views #main-toc,<br \/>\n        #content_views.htmledit_views #hr-toc,<br \/>\n        #content_views.htmledit_views p[id*=\\&#8221;-toc\\&#8221;] {<br \/>\n          display: none !important;<br \/>\n        }<br \/>\n        \/* \u76ee\u5f55\u53bb\u6389\u540e\uff0c\u7d27\u8ddf\u7684\u9996\u4e2a\u6807\u9898\u4e0d\u518d\u591a\u51fa\u4e00\u5757\u4e0a\u8fb9\u8ddd *\/<br \/>\n        #content_views.markdown_views &gt; .toc + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + h4,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h4 {<br \/>\n          margin-top: 0 !important;<br \/>\n        }<\/p>\n<p>\u5199\u524d\u7aef\u4ee3\u7801\u65f6\uff0c\u6211\u4eec\u7ecf\u5e38\u9047\u5230\u4e24\u79cd\u7528\u6cd5\uff1a<\/p>\n<p><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>script<\/span> <span class=\"token attr-name\">src<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=<\/span><span class=\"token punctuation\">\\&#8221;<\/span>.\/xxdemo.js<span class=\"token punctuation\">\\&#8221;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token script\"><\/span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>script<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span> hello <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">\\&#8217;.\/xxdemo.js\\&#8217;<\/span><\/p>\n<p>\u540c\u6837\u662f JS \u6587\u4ef6\uff0c\u4e3a\u4ec0\u4e48\u52a0\u8f7d\u65b9\u5f0f\u4e0d\u540c\uff1f\u4e3a\u4ec0\u4e48\u6709\u4e9b\u5e93\u4f1a\u5199 window.xxx\uff0c\u6709\u4e9b\u5e93\u5374\u4f7f\u7528 export\uff1fIIFE \u53c8\u662f\u4ec0\u4e48\uff0c\u4e3a\u4ec0\u4e48\u8981\u8ba9\u51fd\u6570\u5b9a\u4e49\u540e\u7acb\u5373\u6267\u884c\uff1f<\/p>\n<h3>1. JS\u3001TS\u3001ESM\u3001npm\uff0c\u5206\u522b\u5728\u8bf4\u4ec0\u4e48\uff1f<\/h3>\n<p>\u5148\u5206\u6e05\u5b83\u4eec\u63cf\u8ff0\u7684\u5c42\u9762\uff1a<\/p>\n<table>\n<tr>\n   \u540d\u79f0<br \/>\n   \u63cf\u8ff0\u7684\u4e8b\u60c5<br \/>\n   \u7b80\u5355\u7406\u89e3<br \/>\n  <\/tr>\n<tbody>\n<tr>\n<td>JavaScript\uff0c\u7b80\u79f0 JS<\/td>\n<td>\u7f16\u7a0b\u8bed\u8a00<\/td>\n<td>\u7f16\u5199\u6d4f\u89c8\u5668\u6267\u884c\u7684\u903b\u8f91<\/td>\n<\/tr>\n<tr>\n<td>TypeScript\uff0c\u7b80\u79f0 TS<\/td>\n<td>\u5e26\u7c7b\u578b\u7cfb\u7edf\u7684\u8bed\u8a00<\/td>\n<td>\u5f00\u53d1\u65f6\u589e\u52a0\u7c7b\u578b\u68c0\u67e5\uff0c\u901a\u5e38\u8f6c\u6362\u4e3a JS \u540e\u4ea4\u4ed8<\/td>\n<\/tr>\n<tr>\n<td>ESM<\/td>\n<td>JavaScript \u7684\u6807\u51c6\u6a21\u5757\u673a\u5236<\/td>\n<td>\u7528 import \u548c export \u5171\u4eab\u529f\u80fd<\/td>\n<\/tr>\n<tr>\n<td>IIFE<\/td>\n<td>\u4e00\u79cd\u51fd\u6570\u8868\u8fbe\u5f0f\u5199\u6cd5<\/td>\n<td>\u51fd\u6570\u5b9a\u4e49\u540e\u7acb\u5373\u8c03\u7528\uff0c\u5e38\u7528\u4e8e\u9694\u79bb\u5185\u90e8\u53d8\u91cf<\/td>\n<\/tr>\n<tr>\n<td>npm<\/td>\n<td>\u8f6f\u4ef6\u5305\u7ba1\u7406\u548c\u5206\u53d1<\/td>\n<td>\u5b89\u88c5\u4f9d\u8d56\u3001\u7ba1\u7406\u7248\u672c\u3001\u53d1\u5e03\u4ee3\u7801\u5305<\/td>\n<\/tr>\n<tr>\n<td>Vite\u3001esbuild \u7b49<\/td>\n<td>\u5f00\u53d1\u548c\u6784\u5efa\u5de5\u5177<\/td>\n<td>\u8f6c\u6362\u6e90\u7801\u3001\u5904\u7406\u4f9d\u8d56\u3001\u751f\u6210\u53d1\u5e03\u6587\u4ef6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u56e0\u6b64\uff0c\u201c\u4f7f\u7528 JS \u8fd8\u662f ESM\u201d\u5e76\u4e0d\u662f\u4e24\u4e2a\u5e76\u5217\u9009\u9879\u3002\u91c7\u7528 ESM \u65f6\uff0c\u5199\u7684\u4ecd\u7136\u53ef\u4ee5\u662f JavaScript\u3002<\/p>\n<p>TypeScript \u7684\u7c7b\u578b\u4e3b\u8981\u5728\u5f00\u53d1\u9636\u6bb5\u5e2e\u52a9\u68c0\u67e5\u4ee3\u7801\uff0c\u4e0d\u4f1a\u4f5c\u4e3a\u7c7b\u578b\u68c0\u67e5\u903b\u8f91\u81ea\u52a8\u5e26\u5230\u6d4f\u89c8\u5668\u4e2d\u3002\u53c2\u8003\uff1aTypeScript \u5b98\u65b9\u5165\u95e8<\/p>\n<h3>2. \u666e\u901a script \u662f\u600e\u4e48\u4f7f\u7528 JS \u7684\uff1f<\/h3>\n<p>\u672c\u6587\u628a\u6ca1\u6709 type=\\&#8221;module\\&#8221; \u7684 JavaScript \u811a\u672c\u79f0\u4e3a\u201c\u666e\u901a\u811a\u672c\u201d\uff0c\u4e5f\u53eb\u7ecf\u5178\u811a\u672c\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u4e00\u4e2a\u5b8c\u6574\u7684 HTML \u9875\u9762\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n<p><span class=\"token doctype\"><span class=\"token punctuation\">&lt;!<\/span><span class=\"token doctype-tag\">DOCTYPE<\/span> <span class=\"token name\">html<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>html<\/span> <span class=\"token attr-name\">lang<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=<\/span><span class=\"token punctuation\">\\&#8221;<\/span>zh-CN<span class=\"token punctuation\">\\&#8221;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>head<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>meta<\/span> <span class=\"token attr-name\">charset<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=<\/span><span class=\"token punctuation\">\\&#8221;<\/span>UTF-8<span class=\"token punctuation\">\\&#8221;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>title<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>xxdemo \u666e\u901a\u811a\u672c\u793a\u4f8b<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>title<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>head<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>body<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>p<\/span> <span class=\"token attr-name\">id<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=<\/span><span class=\"token punctuation\">\\&#8221;<\/span>output<span class=\"token punctuation\">\\&#8221;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>p<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>script<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token script\"><span class=\"token language-javascript\"><br \/>\n    <span class=\"token keyword\">function<\/span> <span class=\"token function\">hello<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">name<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/p>\n<p>     <\/span><br \/>\n      <span class=\"token keyword\">return<\/span> <span class=\"token string\">\\&#8217;\u4f60\u597d\uff0c\\&#8217;<\/span> <span class=\"token operator\">+<\/span> name<br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    document<span class=\"token punctuation\">.<\/span><span class=\"token function\">getElementById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;output\\&#8217;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>textContent <span class=\"token operator\">=<\/span> <span class=\"token function\">hello<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;xxdemo\\&#8217;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n  <\/span><\/span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>script<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>body<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>html<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u8fd9\u91cc\u7684\u4ee3\u7801\u7531\u6d4f\u89c8\u5668\u76f4\u63a5\u6267\u884c\u3002\u4e5f\u53ef\u4ee5\u628a\u811a\u672c\u79fb\u5230\u5916\u90e8\u6587\u4ef6\uff0c\u518d\u901a\u8fc7 src \u52a0\u8f7d\u3002<\/p>\n<p>\u6587\u4ef6\u4ee5 .js \u7ed3\u5c3e\uff0c\u5e76\u4e0d\u80fd\u8bf4\u660e\u5b83\u662f\u666e\u901a\u811a\u672c\u8fd8\u662f ESM\u3002 \u8fd8\u8981\u770b\u6587\u4ef6\u5185\u5bb9\uff0c\u4ee5\u53ca\u5b83\u88ab\u600e\u6837\u52a0\u8f7d\u3002\u53c2\u8003\uff1aMDN script \u5143\u7d20<\/p>\n<h3>3. window.xxx \u662f\u4ec0\u4e48\uff1f<\/h3>\n<p>\u5728\u6d4f\u89c8\u5668\u9875\u9762\u91cc\uff0cwindow \u662f\u5168\u5c40\u5bf9\u8c61\u3002\u4e0b\u9762\u7684\u4ee3\u7801\u7ed9\u5b83\u589e\u52a0\u4e86\u4e00\u4e2a\u5c5e\u6027\uff1a<\/p>\n<p>window<span class=\"token punctuation\">.<\/span>XXDemo <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span><br \/>\n  <span class=\"token function\">hello<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">name<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token string\">\\&#8217;\u4f60\u597d\uff0c\\&#8217;<\/span> <span class=\"token operator\">+<\/span> name<br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5176\u4ed6\u811a\u672c\u5c31\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<p>window<span class=\"token punctuation\">.<\/span>XXDemo<span class=\"token punctuation\">.<\/span><span class=\"token function\">hello<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;xxdemo\\&#8217;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u5728\u6ca1\u6709\u540c\u540d\u5c40\u90e8\u53d8\u91cf\u906e\u853d\u7b49\u60c5\u51b5\u4e0b\uff0c\u4e5f\u53ef\u4ee5\u5199\uff1a<\/p>\n<p>XXDemo<span class=\"token punctuation\">.<\/span><span class=\"token function\">hello<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8217;xxdemo\\&#8217;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u628a\u529f\u80fd\u96c6\u4e2d\u5728 XXDemo \u4e0b\u9762\uff0c\u53ef\u4ee5\u907f\u514d\u5c06\u8bb8\u591a\u540d\u5b57\u5206\u522b\u653e\u5230\u5168\u5c40\uff0c\u4f8b\u5982 window.hello\u3001window.reset\u3001window.start\u3002<\/p>\n<p>\u4f46 window.xxx \u672c\u8eab\u4e0d\u662f\u6a21\u5757\u89c4\u8303\u3002\u666e\u901a\u811a\u672c\u53ef\u4ee5\u7ed9\u5b83\u8d4b\u503c\uff0cESM \u4e5f\u53ef\u4ee5\u7ed9\u5b83\u8d4b\u503c\u3002<\/p>\n<h3>4. IIFE \u4e3a\u4ec0\u4e48\u8981\u7acb\u5373\u6267\u884c\uff1f<\/h3>\n<p>IIFE \u7684\u5168\u79f0\u662f Immediately Invoked Function Expression\uff0c\u4e2d\u6587\u53eb\u201c\u7acb\u5373\u6267\u884c\u51fd\u6570\u8868\u8fbe\u5f0f\u201d\u3002<\/p>\n<p>\u666e\u901a\u51fd\u6570\u5f80\u5f80\u5148\u5b9a\u4e49\uff0c\u518d\u8c03\u7528\uff1a<\/p>\n<p><span class=\"token keyword\">function<\/span> <span class=\"token function\">start<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/p>\n<p>   <\/span><br \/>\n  console<span class=\"token punctuation\">.<\/span><span class=\"token function\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content<\/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":[722,187,190],"topic":[],"class_list":["post-110422","post","type-post","status-publish","format-standard","hentry","category-server","tag-ecmascript","tag-javascript","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ece\u666e\u901a script \u5230 ESM\uff1a\u4e00\u6587\u641e\u61c2 JavaScript \u6a21\u5757\u3001IIFE \u548c window - \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\/110422.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4ece\u666e\u901a script \u5230 ESM\uff1a\u4e00\u6587\u641e\u61c2 JavaScript \u6a21\u5757\u3001IIFE \u548c window - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/110422.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-28T08:40:46+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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/110422.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/110422.html\",\"name\":\"\u4ece\u666e\u901a script \u5230 ESM\uff1a\u4e00\u6587\u641e\u61c2 JavaScript \u6a21\u5757\u3001IIFE \u548c window - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-28T08:40:46+00:00\",\"dateModified\":\"2026-09-28T08:40:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/110422.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/110422.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/110422.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ece\u666e\u901a script \u5230 ESM\uff1a\u4e00\u6587\u641e\u61c2 JavaScript \u6a21\u5757\u3001IIFE \u548c window\"}]},{\"@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":"\u4ece\u666e\u901a script \u5230 ESM\uff1a\u4e00\u6587\u641e\u61c2 JavaScript \u6a21\u5757\u3001IIFE \u548c window - \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\/110422.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4ece\u666e\u901a script \u5230 ESM\uff1a\u4e00\u6587\u641e\u61c2 JavaScript \u6a21\u5757\u3001IIFE \u548c window - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content","og_url":"https:\/\/www.wsisp.com\/helps\/110422.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-28T08:40:46+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/110422.html","url":"https:\/\/www.wsisp.com\/helps\/110422.html","name":"\u4ece\u666e\u901a script \u5230 ESM\uff1a\u4e00\u6587\u641e\u61c2 JavaScript \u6a21\u5757\u3001IIFE \u548c window - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-28T08:40:46+00:00","dateModified":"2026-09-28T08:40:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/110422.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/110422.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/110422.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4ece\u666e\u901a script \u5230 ESM\uff1a\u4e00\u6587\u641e\u61c2 JavaScript \u6a21\u5757\u3001IIFE \u548c window"}]},{"@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\/110422","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=110422"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/110422\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=110422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=110422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=110422"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=110422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}