{"id":9268,"date":"2023-03-31T16:56:21","date_gmt":"2023-03-31T08:56:21","guid":{"rendered":"https:\/\/sdeno.com\/?p=9268"},"modified":"2023-03-31T16:56:21","modified_gmt":"2023-03-31T08:56:21","slug":"%e5%bc%95%e5%85%a5%e7%ac%ac%e4%b8%89%e6%96%b9cdn%e4%bd%a0%e4%bc%9a%e5%8f%91%e7%8e%b0vue%e6%9c%89%e5%a4%9a%e4%b8%aa%e4%b8%8d%e5%90%8c%e7%89%88%e6%9c%ac%e5%91%bd%e5%90%8d%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=9268","title":{"rendered":"\u5f15\u5165\u7b2c\u4e09\u65b9cdn\u4f60\u4f1a\u53d1\u73b0vue\u6709\u591a\u4e2a\u4e0d\u540c\u7248\u672c\u547d\u540d\u6587\u4ef6"},"content":{"rendered":"<p>\u5982\u56fe\uff1a<\/p>\n<figure class=\"mdx-lazyload-container\" style=\"max-width:208px\"><div style=\"padding-top:273.07692307692%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"208\" height=\"568\" class=\"alignnone size-full wp-image-9269 lazyload\" title=\"\u5f15\u5165\u7b2c\u4e09\u65b9cdn\u4f60\u4f1a\u53d1\u73b0vue\u6709\u591a\u4e2a\u4e0d\u540c\u7248\u672c\u547d\u540d\u6587\u4ef6\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2023\/03\/clipboard.png\" alt=\"https:\/\/sdeno.com\/wp-content\/uploads\/2023\/03\/clipboard.png\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2023\/03\/clipboard.png 208w, https:\/\/sdeno.com\/wp-content\/uploads\/2023\/03\/clipboard-110x300.png 110w\" sizes=\"auto, (max-width: 208px) 100vw, 208px\"><\/figure>\n<p><span style=\"color: #ff0000;\">cjs<\/span><br \/>\n\u5168\u540dCommonJS\uff0c\u9002\u7528\u4e8e Node \u548c Browserify\/Webpack<\/p>\n<p><span style=\"color: #ff0000;\">runtime<\/span><br \/>\n\u4e0d\u542b compiler\uff08\u7528\u4e8e\u7f16\u8bd1\u7684\uff09 \u7ec4\u4ef6\uff0c\u4e5f\u5c31\u662f\u8bf4\u4e0d\u80fd\u8fd9\u4e48\u5199<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">new Vue({\r\n el: \"#box\",\r\n template: \"&lt;div&gt;{{msg}}&lt;\/div&gt;\", \/\/\u4e0d\u80fd\u4f7f\u7528template\u5c5e\u6027\r\n});<\/pre>\n<p><a href=\"https:\/\/sdeno.com\/?p=8331\" target=\"_blank\" rel=\"noopener\">https:\/\/sdeno.com\/?p=8331<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\">prod<\/span><br \/>\n\u8868\u793a\u8fd9\u4e2a\u662f\u751f\u4ea7\u73af\u5883\u4f7f\u7528\u7684\u7248\u672c\uff0c\u4ee3\u7801\u4f1a\u8fdb\u884c\u4e11\u5316\u538b\u7f29\uff0c\u6709\u4e9b\u53d8\u91cf\u53ef\u80fd\u4f1a\u4f7f\u7528a,b,c\u6765\u4ee3\u66ff<\/p>\n<p><span style=\"color: #ff0000;\">min<\/span><br \/>\n\u4ee3\u7801\u4ec5\u4ec5\u505a\u4e86\u538b\u7f29\u5904\u7406\u5220\u9664\u591a\u4f59\u7a7a\u767d\u3001\u6362\u884c\u800c\u5df2<\/p>\n<p><span style=\"color: #ff0000;\">esm<\/span><br \/>\n\u8ba9\u6d4f\u89c8\u5668\u652f\u6301 &lt;script type=&#8221;module&#8221;&gt; \u8fd9\u6837\u65b9\u6cd5\u5f15\u5165\uff0c\u4f46\u662f\u5bf9\u6d4f\u89c8\u5668\u8981\u6c42\u9ad8<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/\/module.js\r\nexport default function test(){\r\n  return 'test...'\r\n}\r\n\r\n\/\/ index.js\r\nimport test from '.\/module.js';\r\nconsole.log(test())\r\n\r\n\r\n\r\n\r\n&lt;body&gt;\r\n  \/\/ \u2f45\u6cd5 1 \uff1a\u5f15\u2f0amodule.js\uff0c\u7136\u540e\u5728script\u6807\u7b7e\u2fa5\u2faf\u8c03\u2f64\r\n  &lt;script type=\"module\"&gt;\r\n    import test from '.\/module.js';\r\n    console.log(test())\r\n  &lt;\/script&gt;\r\n  \r\n  \/\/ \u2f45\u6cd5 2 \uff1a\u76f4\u63a5\u5f15\u2f0aindex.js\uff0c\u4f7f\u2f64src\u5f15\u2f0a\r\n  &lt;script type=\"module\" src=\".\/index.js\"&gt;&lt;\/script&gt;\r\n&lt;\/body&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\">global<\/span><br \/>\n\u662f\u5305\u542b\u7f16\u8bd1\u5668\u548c\u8fd0\u884c\u65f6\u7684\u201c\u5b8c\u6574\u201d\u6784\u5efa\u7248\u672c<\/p>\n<p><span style=\"color: #ff0000;\">bundler<\/span><br \/>\n\u8bf4\u660e\u6587\u4ef6\u8d70\u4e86\u7c7b\u4f3cwebpack\u3001gulp\u6253\u5305\u751f\u4ea7\u51fa\u6765\u7684<\/p>\n<p><span style=\"color: #ff0000;\">browser<\/span><br \/>\n\u9002\u7528\u4e8e\u6d4f\u89c8\u5668\u4f7f\u7528&lt;script src=&#8221;&#8221;&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u56fe\uff1a cjs \u5168\u540dCommonJS\uff0c\u9002\u7528\u4e8e Node \u548c Browserify\/Webpack runtim [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-9268","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/9268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9268"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/9268\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}