Taro: 不能传递事件?

Created on 27 Jun 2018  ·  4Comments  ·  Source: NervJS/taro

Most helpful comment

这是个bug,正在处理,先这样包一层调用

export default class FontIcon extends Componet<IProps> {
  onClickHandler = () => {
    this.props.onClick()
  }
  return (
    <Text onClick={this.onClickHandler} />
  )
}

All 4 comments

可以查阅下 官方文档做出的妥协 : https://github.com/NervJS/taro/blob/master/docs/event.md

字体还有个性,啥字体?

@crper 我的handleClearValue是写在SearchBar组件里面的,然后想把handleClearValue传递给FontIcon来执行,但是他提示我的是 Do not have onClick handler in current page: pages/index/index. Please make sure that onClick handler has been defined in pages/index/index, or pages/index/index has been added into app.json ,这个错误跟文档说的妥协搭边吗?

这是个bug,正在处理,先这样包一层调用

export default class FontIcon extends Componet<IProps> {
  onClickHandler = () => {
    this.props.onClick()
  }
  return (
    <Text onClick={this.onClickHandler} />
  )
}

最新的 beta 版本修复了这个问题~

Was this page helpful?
0 / 5 - 0 ratings