前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Taro3 不使用 TypeScript 的情况下使用 taro-ui 时报错

Taro3 不使用 TypeScript 的情况下使用 taro-ui 时报错

原创
作者头像
小鑫
发布2022-04-26 14:35:10
9670
发布2022-04-26 14:35:10
举报
文章被收录于专栏:小鑫の随笔小鑫の随笔

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

报错信息

代码语言:javascript
复制
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

首发自:Taro3 不使用 TypeScript 的情况下使用 taro-ui 时报错 - 小鑫の随笔

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 报错信息
相关产品与服务
云开发 CloudBase
云开发(Tencent CloudBase,TCB)是腾讯云提供的云原生一体化开发环境和工具平台,为200万+企业和开发者提供高可用、自动弹性扩缩的后端云服务,可用于云端一体化开发多种端应用(小程序、公众号、Web 应用等),避免了应用开发过程中繁琐的服务器搭建及运维,开发者可以专注于业务逻辑的实现,开发门槛更低,效率更高。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档