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.4 hooks events在小程序端不支持.bind(xxx) #3534

Closed
lbb00 opened this issue Jun 25, 2019 · 2 comments
Closed

Taro v1.3.4 hooks events在小程序端不支持.bind(xxx) #3534

lbb00 opened this issue Jun 25, 2019 · 2 comments
Assignees

Comments

@lbb00
Copy link

lbb00 commented Jun 25, 2019

问题描述
Taro v1.3.4 hooks events在小程序端不支持.bind(xxx)

复现步骤

function Foo  {
  function bar (some){ console.log(some)}
  return (
    <View onClick={bar.bind(null, 'hello')}><View>
  )
}

报错信息

thirdScriptError
Cannot read property 'apply' of undefined; [Component] Event Handler Error @ components/XcTabs/index#(anonymous)
TypeError: Cannot read property 'apply' of undefined
    at ye.obj.(anonymous function) [as handleBarClick] (http://127.0.0.1:53785/appservice/npm/@tarojs/taro-weapp/dist/index.js:1796:35)
    at Object.r.safeCallback (WAService.js:1:857898)
    at WAService.js:1:1048426
    at r (WAService.js:1:982076)
    at WAService.js:1:982184
    at WAService.js:1:253666
    at e (http://127.0.0.1:53785/appservice/appservice?t=1561446687534:1499:20972)
    at r.registerCallback.t (http://127.0.0.1:53785/appservice/appservice?t=1561446687534:1499:21157)
    at l.forEach.t (http://127.0.0.1:53785/appservice/appservice?t=1561446687534:1499:1581)
    at Array.forEach (<anonymous>)

检查生成的文件发现,function bar 没有被映射到class上。

暂时时只能用下面这种方式解决。

<View onClick={ () => { bar('hello') } }><View>

系统信息

Taro v1.3.4

@taro-bot
Copy link

taro-bot bot commented Jun 25, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@taro-bot
Copy link

taro-bot bot commented Jun 25, 2019

CC @yuche

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

2 participants