taro3-不使用-typescript-的情况下使用-taro-ui-时报错

最近有个小程序的项目,用 taro3 脚手架创建了项目,在组件里引入了 taro-ui 的组件之后,执行 yarn dev:weapp 一直报错,报错内容是无法识别 taro-ui 里面的 ts 语法

报错信息

Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /Users/chenlin/workspace/taro_test/node_modules/taro-ui/dist/weapp/components/swipe-action/index.tsx: Unexpected token, expected "{" (22:54)

20 | import AtSwipeActionOptions from './options/index'
21 |

22 | export default class AtSwipeAction extends AtComponent<
| ^
23 | AtSwipeActionProps,
24 | AtSwipeActionState
25 | > {
     
...

(node:6474) UnhandledPromiseRejectionWarning: [object Array]
(node:6474) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6474) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

后来搜了下官方 issue,发现有人遇到过这个问题,原因是 taro-ui 2.x 跟 taro 3.x 不兼容,需要安装 3.x 的 taro-ui

issue 地址:https://github.com/NervJS/taro-ui/issues/1179

阅读原文:小鑫の随笔

你可能感兴趣的:(踩坑记录,reactjs,node.js,typescript,es6,javascript)