Skip to content

Commit

Permalink
feat(docs): 更新 2.0 版本使用 async-await 的文档 #4837
Browse files Browse the repository at this point in the history
  • Loading branch information
Garfield550 authored and luckyadam committed Jan 7, 2020
1 parent 3f20e03 commit 116805e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/async-await.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
title: 异步编程
---

Taro 支持使用 `async functions` 来让开发者获得不错的异步编程体验,开启 `async functions` 支持需要使用到 `babel-plugin-transform-runtime` 插件,请按如下操作
> Taro 2.x 版本中使用 `async-await` 不再需要 `@tarojs/async-await`
首先需要在项目中分别安装 `babel-plugin-transform-runtime``babel-runtime` 两个包
Taro 支持使用 `async functions` 来让开发者获得不错的异步编程体验,开启 `async functions` 支持需要安装包 `babel-plugin-transform-runtime``babel-runtime`

```bash
$ yarn add babel-plugin-transform-runtime --dev
$ yarn add babel-runtime
```

随后修改项目 [`babel` 配置](./config-detail.md#babel),增加插件 `babel-plugin-transform-runtime`
随后修改项目 [`babel` 配置](./config-detail.md#babel),增加插件 `babel-plugin-transform-runtime`

```js
babel: {
Expand All @@ -38,4 +38,4 @@ babel: {
}
```

这样就能直接在项目中使用 `async functions` 了。
> 值得注意的事,使用 `async functions` 一定要记得按照[开发前注意](./before-dev-remind.md)中提示的内容进行操作,否则会出现报错

0 comments on commit 116805e

Please sign in to comment.