Babel的简单使用
Babel的简单使用
1.初始化,创建package.json
npm init
2.安装babel-cli
npm i -d babel-cli
3.安装babel
npm i -d babel-preset-latest
4.添加 .babelrc 文件
a.创建
type nul>.babel
b.内容
{ "presets":["latest"], "plugins":[] }
5.创建src、release 文件夹
6.修改package.json
{ ... "scripts": { ... "build":"babel src -d release" }, }
"babel js -d release" 可理解为"把src文件夹下的js文件转换后存到release文件夹下"
7.编写示例代码( src/test.js)
let arr=[1,3,5,6,8,9];
8.运行
npm run build > [email protected] build D:\webWork\es6test > babel src -d release src\test.js -> release\test.js
9.结果(release/test.js)
"use strict"; var arr = [1, 3, 5, 6, 8, 9];
相关推荐
PANH 2020-01-23
82530995 2020-10-15
ruanhongbiao 2020-08-16
FEvivi 2020-06-16
FEvivi 2020-06-13
PANH 2020-06-12
zhongweinan 2020-06-10
PANH 2020-06-07
PANH 2020-06-01
82530995 2020-05-10
webfullStack 2020-04-26
zhongweinan 2020-04-24
FEvivi 2020-04-17
FEvivi 2020-04-15
zhongweinan 2020-03-03
zhongweinan 2020-02-21
PANH 2020-02-19
zhongweinan 2020-01-21
上海彭彭 2020-01-14