NonClockworkChen
V2EX  ›  问与答

请教如何搭建一个 ES7 的测试环境...

  •  
  •   NonClockworkChen · Aug 29, 2017 · 1840 views
    This topic created in 3200 days ago, the information mentioned may be changed or developed.
    我想测试一下 decorator 语法
    babel 的在线 REPL,没法测试这个语法.
    本地 babel,不知道应该配合什么搭建,教程什么的,有点乱.
    6 replies    2017-08-30 01:41:21 +08:00
    noe132
        1
    noe132  
       Aug 29, 2017   ❤️ 1
    http://kangax.github.io/compat-table/esnext/

    似乎只有 Type-Script + core-js 支持
    noe132
        2
    noe132  
       Aug 29, 2017   ❤️ 1
    草案里的很多功能很少有支持的。。只有极个别的有个别平台支持。
    noe132
        3
    noe132  
       Aug 29, 2017   ❤️ 1
    https://babeljs.io/docs/plugins/transform-decorators/

    如果是按照这个的话安装 node,新建文件夹 npm install babel,写好 js 后 ./node_modules/.bin/babel --plugins transform-decorators script.js 就能得到编译后的结果了。
    NonClockworkChen
        4
    NonClockworkChen  
    OP
       Aug 29, 2017
    @noe132 http://blog.csdn.net/LaurenTime/article/details/75315218

    按照这个把.babelrc 配置一下,babel-node 就能运行了,美滋滋
    doublleft
        5
    doublleft  
       Aug 29, 2017
    你可以直接包裹嘛 HOC()(Component)
    fulvaz
        6
    fulvaz  
       Aug 30, 2017
    等等, decorator 还是 stage2, es7 里面没有, es8 页没有吧? 所以 babel 在线 repl 不能用...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1194 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 93c8b4a0 · 34ms · UTC 17:41 · PVG 01:41 · LAX 10:41 · JFK 13:41
    ♥ Do have faith in what you're doing.