Skip to content

Commit 85f0cfe

Browse files
committed
fix typo
1 parent 1ed8d1d commit 85f0cfe

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

docs/decorator.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,16 +571,28 @@ class MyClass {}
571571

572572
## Babel转码器的支持
573573

574-
目前,Babel转码器已经支持Decorator,命令行的用法如下。
574+
目前,Babel转码器已经支持Decorator。
575+
576+
首先,安装`babel-core``babel-plugin-transform-decorators`。由于后者包括在`babel-preset-stage-0`之中,所以改为安装`babel-preset-stage-0`亦可。
575577

576578
```bash
577-
$ babel --optional es7.decorators
579+
$ npm install babel-core babel-plugin-transform-decorators
578580
```
579581

582+
然后,设置配置文件`.babelrc`
583+
584+
```javascript
585+
{
586+
"plugins": ["transform-decorators"]
587+
}
588+
```
589+
590+
这时,Babel就可以对Decorator转码了。
591+
580592
脚本中打开的命令如下。
581593

582594
```javascript
583-
babel.transform("code", {optional: ["es7.decorators"]})
595+
babel.transform("code", {plugins: ["transform-decorators"]})
584596
```
585597

586598
Babel的官方网站提供一个[在线转码器](https://babeljs.io/repl/),只要勾选Experimental,就能支持Decorator的在线转码。

docs/module.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ TypeError: even is not a function
689689

690690
## ES6模块的转码
691691

692-
浏览器目前还不支持ES6模块,为了现在就能使用,可以将转为ES5的写法。
692+
浏览器目前还不支持ES6模块,为了现在就能使用,可以将转为ES5的写法。除了Babel可以用来转码之外,还有以下两个方法,也可以用来转码。
693693

694694
### ES6 module transpiler
695695

@@ -707,7 +707,7 @@ $ npm install -g es6-module-transpiler
707707
$ compile-modules convert file1.js file2.js
708708
```
709709

710-
o参数可以指定转码后的文件名
710+
`-o`参数可以指定转码后的文件名
711711

712712
```bash
713713
$ compile-modules convert -o out.js file1.js

docs/promise.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ ES6的Promise API提供的方法不是很多,有些有用的方法可以自己
525525
526526
### done()
527527
528-
Promise对象的回调链,不管以`then`方法或`catch`方法结尾,要是最后一个方法抛出错误,都有可能无法漏掉(Promise内部的错误不会冒泡到全局)。因此,我们可以提供一个`done`方法,总是处于回调链的尾端,保证抛出任何可能出现的错误。
528+
Promise对象的回调链,不管以`then`方法或`catch`方法结尾,要是最后一个方法抛出错误,都有可能无法捕捉到(因为Promise内部的错误不会冒泡到全局)。因此,我们可以提供一个`done`方法,总是处于回调链的尾端,保证抛出任何可能出现的错误。
529529
530530
```javascript
531531
asyncFunc()

0 commit comments

Comments
 (0)