taro 挖坑填坑

看了两周的文档,3月终于开始上手taro了,一套代码可以编译h5、小程序、rn,何乐而不为呢?

然后就遇到各种各样的坑


taro ui

错误:

Failed to compile.

./node_modules/taro-ui/dist/h5/components/countdown/index.js 105:11

Module parse failed: Unexpected token (105:11)

You may need an appropriate loader to handle this file type.

|    } = this.state;

| 

>    return <View className={classNames({

|      'at-countdown': true,

|      'at-countdown--card': isCard

解决:

在 'config/index' 中 引入


h5: {

esnextModules: ['taro-ui']

}

思考:

不好好看文档!

参考:https://github.com/NervJS/taro-ui/issues/423


异步的问题

问题:

regeneratorRuntime is not defined

解决:

$ yarn add @tarojs/async-await
# 或者使用 npm
$ npm install --save @tarojs/async-await

在有异步操作的页面引入 import '@tarojs/async-await'

思考:

又不好好看文档!

参考:https://nervjs.github.io/taro/docs/async-await.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容