Babel

Babel

1、babel有非常多的版本,可以通过多种方式引用,在链接1中可以查看到所有支持的版本。

2、对node版本的安装与使用,分以下几步:

  1)install

    

  2)使用transform api 转换代码

    

  3)安装preset

    

    In order to enable the preset you have to define it in your .babelrc file, like this:

    

 3、presets字段设定转码规则,官方提供以下的规则集,你可以根据需要安装

  

4、Compile the entire src directory and output it to the lib directory. You may use --out-dir or -d. This doesn’t overwrite any other files or directories in lib.

  

参考:

1、http://babeljs.io/docs/setup/

2、http://www.ruanyifeng.com/blog/2016/01/babel.html?20170213113809

原文地址:https://www.cnblogs.com/tekkaman/p/6393137.html