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
使用有赞日历组件,函数传不进去 #8495
Comments
升级到最新版再试试 |
@Chen-jj taro 3.0.23 版本,Vue 下也是同样情况 |
@Teemwu React 不能给基础组件设置函数值的 props,暂时没有办法。 |
This comment was marked as outdated.
This comment was marked as outdated.
@Chen-jj 这个hack方法没有用 |
上述回答的代码不正确。应该先给函数属性一个默认值,不然 Taro 在编译时不知道需要把该属性输出到 wxml 里。 export default class Index extends Component {
el = React.createRef()
onReady () {
Taro.nextTick(() => {
this.el.current.setAttribute('formatter', this.formatter)
})
}
formatter () {
return function (day) {
console.log('formatter', day)
}
}
render () {
return (
<View>
<van-calendar ref={this.el} formatter={null} show={true} />
</View>
)
}
} |
收到,明天上班的时候再试一次 |
@Chen-jj 我用的是useReady Hook,这个hack不会每次都成功。useEffect+nextTick倒是每次都可以。
|
是真机么?模拟器上倒是 ok |
@Chen-jj 模拟器。似乎某些警告会导致失败。 |
加一句 |
@smoothdvd 看来还是要加 nextTick,我修改一下回复里的代码,感谢反馈~ |
vue怎么解决呢 |
相关平台
微信小程序
小程序基础库: 2.14.1
使用框架: React
复现步骤
期望结果
formatter不为null
实际结果
formatter为null
环境信息
The text was updated successfully, but these errors were encountered: