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 event handler 传递参数有问题 #15

Open
sisterAn opened this issue Feb 16, 2019 · 0 comments
Open

Taro event handler 传递参数有问题 #15

sisterAn opened this issue Feb 16, 2019 · 0 comments

Comments

@sisterAn
Copy link
Owner

如果,你在开发过程中,发现event handler 传递参数有问题,例如:代码里使用onClick={this.handleClick.bind(this, 1)}的方式绑定事件处理程序,并且传递值,其定义是

// 方法
handleClick (params , e) {
    console.log('params:', params)
    console.log('e:', e)
}
// render
<View className='flexDirection-c'>
     <View className='base-width-12 lh-22 tx-c fs-14' onClick={this.handleClick.bind(this, -1)}>全部商品</View>
     <View className='base-width-12 lh-22 tx-c fs-14' onClick={this.handleClick.bind(this, 0)}>在售商品</View>
     <View className='lh-22 tx-c fs-14' onClick={this.handleClick.bind(this, 1)}>下架商品</View>
</View>

打印结果你如果看到:
在这里插入图片描述
而我们所期望的结果是:
在这里插入图片描述
这是因为你项目中的taro-cli与依赖的版本不同,升级依赖即可,
项目中必须确保 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

1 participant