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然后taro转换成微信小程序所有组件点击时报错Cannot read property 'apply' of undefined #2141

Closed
luodanyalian opened this issue Feb 12, 2019 · 8 comments

Comments

@luodanyalian
Copy link

luodanyalian commented Feb 12, 2019


问题描述
微信小程序转taro然后taro转换成微信小程序点击组件时报错,所有组件点击事件都报这个错:

thirdScriptError
Cannot read property 'apply' of undefined; [Component] Event Handler Error @ components/selectbar/selectbar#(anonymous)
TypeError: Cannot read property 'apply' of undefined

系统信息
System:
OS: macOS 10.14
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
Yarn: 1.9.4 - ~/.nvm/versions/node/v8.11.3/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.11.3/bin/npm

@taro-bot
Copy link

taro-bot bot commented Feb 12, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@luodanyalian luodanyalian changed the title 微信小程序转taro然后taro转换成微信小程序点击组件时报错Cannot read property 'apply' of undefined 微信小程序转taro然后taro转换成微信小程序所有组件点击时报错Cannot read property 'apply' of undefined Feb 12, 2019
@yuche
Copy link
Contributor

yuche commented Feb 14, 2019

请提供一下微信小程序源码

@jianguo1202
Copy link

请问楼主解决了吗

@luodanyalian
Copy link
Author

请问楼主解决了吗

没有解决,之前忙,没有看这个问题

@Xiaolong145682
Copy link

应该是组件里用到的方法没有定义造成的,我这边也遇到了类似的问题,检查了一下发现是组件里用到的一个方法没有定义,才出现这样的错误提示!

@jsdchenye
Copy link

jsdchenye commented May 24, 2019

请问楼主解决了吗

没有解决,之前忙,没有看这个问题

请提供一下微信小程序源码

我这里也复现这个问题。
const testArr = [ { content: '1234567', trigger: () => { console.log(111); }, }, ]; return ( <View> { testArr.map((item, index) => ( <View className="mes-body" key={index}> { <View onClick={item.trigger} > {item.content} </View> } </View> )) } </View> )

@Anjing1993
Copy link

箭头函数貌似可以解决这个问题:
举个栗子额:
将 onClick={onClick.bind(this, props)} 改为 onClick={() => onClick(props) }

@Xiaolong145682
Copy link

Xiaolong145682 commented Jul 28, 2019 via email

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

7 participants