{"id":94053,"date":"2020-04-23T06:29:32","date_gmt":"2020-04-22T22:29:32","guid":{"rendered":"http:\/\/4563.org\/?p=94053"},"modified":"2020-04-23T06:29:32","modified_gmt":"2020-04-22T22:29:32","slug":"%e8%af%b7%e6%95%99-babel-%e5%86%85%e8%81%94%e8%bd%ac%e8%af%91%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=94053","title":{"rendered":"\u8bf7\u6559 babel \u5185\u8054\u8f6c\u8bd1\u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559 babel \u5185\u8054\u8f6c\u8bd1\u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : phpxiaowangzi <\/span>  <span><i><\/i> 17<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5982\u9898\uff0c index.html<\/p>\n<pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;  &lt;title&gt;demo&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt; &lt;script src=\"https:\/\/cdn.bootcss.com\/babel-core\/5.8.23\/browser.js\"&gt;&lt;\/script&gt; &lt;script src=\"script.js\" type=\"text\/babel\"&gt; &lt;\/script&gt; &lt;\/body&gt; &lt;\/html&gt;  <\/code><\/pre>\n<p>script.js<\/p>\n<pre><code>const add = (x=5,y=6) =&gt; console.log(x+y);  <\/code><\/pre>\n<p>\u8bbf\u95ee\u6d4f\u89c8\u5668\uff0c\u4f7f\u7528\u5f00\u53d1\u8005\u5de5\u5177\u67e5\u770b\u5e76\u672a\u53d1\u73b0\u6709\u8f6c\u8bd1\uff0c\u662f\u54ea\u91cc\u64cd\u4f5c\u9519\u8bef\u4e86\u5417 \u4f7f\u7528\u4e86 babel5 \u6765\u8fdb\u884c\u5185\u8054\u5f0f\u64cd\u4f5c<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1186529\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : autoxbc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u5728 script.js \u91cc\u52a0\u4e86\u4e00\u53e5 add() \uff0c\u6210\u529f\u8f93\u51fa 11\uff0c\u8bf4\u660e\u662f\u8f6c\u8bd1\u6210\u529f\u4e86\uff0c\u7528\u7684\u662f\u4e0d\u652f\u6301 ES6 \u7684\u6d4f\u89c8\u5668<\/p>\n<p>\u4f60\u8bf4\u6ca1\u8f6c\u8bd1\u6210\u529f\u662f\u6307\u76f4\u63a5\u770b script.js \u7684\u5185\u5bb9\uff1f\u90a3\u4e2a\u4e0d\u4f1a\u53d8\u7684\uff0cbabel \u5185\u8054\u8f6c\u8bd1\u5e94\u8be5\u662f es6 string =&gt; es5 string =&gt; eval(es5 string)\uff0c\u5982\u679c\u4f60 hook eval \u65b9\u6cd5\uff0c\u53ef\u4ee5\u770b\u5230\u90a3\u4e2a es5 string                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1186530\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : autoxbc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ee5\u53ca\u5728\u6bd4\u8f83\u65b0\u7684\u6d4f\u89c8\u5668\u4e2d\u6d4b\u8bd5\u65f6\uff0cindex.html \u5fc5\u987b\u653e\u5165 web server \u7528 http \u534f\u8bae\u8bbf\u95ee<\/p>\n<p>\u76f4\u63a5\u7528\u6d4f\u89c8\u5668\u6253\u5f00\u662f file:\/\/ \u534f\u8bae\uff0c\u5728 Firefox \u4e2d\u4f1a\u51fa\u73b0 CORS \u9519\u8bef\uff0c\u5728 Chrome \u4e2d\u4f1a\u51fa\u73b0 sessionStorage \u9519\u8bef                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1186531\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : phpxiaowangzi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @autoxbc \u611f\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559 babel \u5185\u8054\u8f6c\u8bd1\u7684\u95ee\u9898 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/94053"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=94053"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/94053\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94053"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}