争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

如何封装一个React Native多级联动(代码完成)

时间:2024/6/1作者:未知来源:争怎路由网人气:

0 } else if (index === currentIndex) { // 当前级等于发生变化的层级, 选中项是传来的itemIndex childIndex = itemIndex } else { // 当前级大于发生变化的层级, 选中项应该置为默认0,因为下级的选项会随着上级的变化而变化 childIndex = 0 } indexArr[index] = childIndex if (arr[childIndex] && arr[childIndex].children) { const nextIndex = index + 1 re(arr[childIndex].children, nextIndex) } } } re(options, 0) this.setState( { indexs: indexArr // 重置所有选中项,重新渲染 }, () => { this.props.onChange && this.props.onChange(indexArr) } ) } renderItems () { // 拼装选择项组 const items = [] const { options = [], indexs = [] } = this.state const re = (arr, index) => { // index为第几级 if (arr && arr.length > 0) { const childIndex = indexs[index]

关键词:如何封装一个React Native多级联动(代码完成)




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版