We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
问题描述 微信小程序端-jsx中map套map,onclick事件传递subitem错误
export default () => { const data = [ { arr: [1, 2, 3, 4] }, { arr: [5, 6, 7, 8] } ]; const click = num => { // 这里的num是错误的 console.log(num); }; return ( <View> {data.map(a => ( <View> {a.arr && a.arr.map(n => <Button onClick={() => click(n)}>{n}</Button>)} </View> ))} </View> ); };
期望行为 click事件中传递的参数正常传递
报错信息 click中的参数异常
系统信息
补充信息 暂时的解决方案
export default () => { const data = [ { arr: [1, 2, 3, 4] }, { arr: [5, 6, 7, 8] } ]; const temp: any = []; const click = num => { console.log(num); }; return ( <View> {data.map((a, i) => { temp[i] = [] return ( <View> {a.arr && a.arr.map((n, j) => { temp[i][j] = n return ( <Button onClick={() => { const t = temp[i][j] click(t); }} > {n} </Button> ); })} </View> ); })} </View> ); };
The text was updated successfully, but these errors were encountered:
欢迎提交 Issue~
如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏
如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。
Good luck and happy coding~
Sorry, something went wrong.
你的函数调用貌似没有穿入参数
这样试试
a.arr.map(n => <Button onClick={this.click.bind(this,n)}>{n}</Button>)
你的函数调用貌似没有穿入参数 这样试试 a.arr.map(n => <Button onClick={this.click.bind(this,n)}>{n}</Button>)
试过了,不行的
CC @yuche
13585cf
yuche
No branches or pull requests
问题描述
微信小程序端-jsx中map套map,onclick事件传递subitem错误
期望行为
click事件中传递的参数正常传递
报错信息
click中的参数异常
系统信息
补充信息
暂时的解决方案
The text was updated successfully, but these errors were encountered: