Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taro v1.3.8 hooks组件作为page时,报错:未找到 Taro.Component 的类定义 #3760

Closed
lbb00 opened this issue Jul 10, 2019 · 16 comments
Assignees

Comments

@lbb00
Copy link

lbb00 commented Jul 10, 2019

报错信息

错误  页面编译  页面/Users/onelong/work/ilisten-taro-pack/src/pages/playing/index编译失败!
Error: 未找到 Taro.Component 的类定义
    at transform (/usr/local/lib/node_modules/@tarojs/cli/node_modules/_@tarojs_transformer-wx@1.3.8@@tarojs/transformer-wx/lib/src/index.js:623:15)
    at Object.<anonymous> (/usr/local/lib/node_modules/@tarojs/cli/dist/mini/page.js:87:37)
    at Generator.next (<anonymous>)
    at /usr/local/lib/node_modules/@tarojs/cli/dist/mini/page.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/@tarojs/cli/dist/mini/page.js:3:12)
    at Object.buildSinglePage (/usr/local/lib/node_modules/@tarojs/cli/dist/mini/page.js:25:12)
    at Object.<anonymous> (/usr/local/lib/node_modules/@tarojs/cli/dist/mini/watch.js:67:34)
    at Generator.next (<anonymous>)
    at /usr/local/lib/node_modules/@tarojs/cli/dist/mini/watch.js:7:71

系统信息

Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。

  • 操作系统: Mac
  • Taro 版本 v1.3.8
  • Node.js 版本 v12
  • 报错平台 weapp
@taro-bot
Copy link

taro-bot bot commented Jul 10, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@taro-bot
Copy link

taro-bot bot commented Jul 10, 2019

CC @yuche

@luckyadam
Copy link
Member

确实有问题,暂时不要用函数式组件来写页面吧

@lbb00
Copy link
Author

lbb00 commented Jul 10, 2019

不行哦。因为需要多个context。不用函数式组件做不到鸭

@lbb00
Copy link
Author

lbb00 commented Jul 10, 2019

1.3.5的时候还正常的喔

@nanjingboy
Copy link
Member

nanjingboy commented Jul 11, 2019

@luckyadam 这个在 <= 1.3.6 之前都是 OK 的

@wanghui47
Copy link

@luckyadam 您好,看到您说 “确实有问题,暂时不要用函数式组件来写页面吧”; 但是我这个 3767 是全部官方默认的,没有写新的组件,也出现这个问题,是因为官方的 mobx 模板里面有使用函数式组件吗?

@nanjingboy
Copy link
Member

@wanghui47 这个在 <= 1.3.6 之前是 OK 的,需要 @luckyadam 检查下 1.3.7 改了什么导致这个问题

@wanghui47
Copy link

@nanjingboy 好的,谢谢您。

@yuche yuche closed this as completed in 65483aa Jul 11, 2019
@hqman
Copy link

hqman commented Jul 11, 2019

@yuche 我想用master代码 自己编一个 taro-transformer-wx 替换全局安装taro-cli的代码
但是遇到一个问题?
运行 build (tsc) 出现一大推error,该如何解决?

src/functional.ts:27:58 - error 
TS2345: Argument of type 'babel.types.LVal[]'
 is not assignable to parameter of type 'import("/Users/xxx/project/plays/taro/

@yuche
Copy link
Contributor

yuche commented Jul 11, 2019

@hqman 因为你安装依赖没有按 package.json.lock 来装

@hqman
Copy link

hqman commented Jul 11, 2019

多谢 @yuche 用master代码 打了个包, 函数组件又可以用了! 👍

@czhhgghm
Copy link

czhhgghm commented Oct 3, 2019

好想知道这个问题最后怎么解决呢

@zicong-zhang
Copy link

我也想知道怎么解决, export default memo(AAA); 这种写法会导致 TS 不会检测自动导入

@langxiaohui123
Copy link

Error: 未找到 Taro.Component 的类定义
at transform (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs/transformer-wx/lib/src/index.js:623:15)
at /usr/local/lib/node_modules/@tarojs/cli/dist/mini/page.js:87:37
请问你们怎么解决的?

@StarRain-L
Copy link

Error: 未找到 Taro.Component 的类定义 at transform (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs/transformer-wx/lib/src/index.js:623:15) at /usr/local/lib/node_modules/@tarojs/cli/dist/mini/page.js:87:37 请问你们怎么解决的?

试试重新安装taro "npm install -g @tarojs/cli"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants