zoukankan      html  css  js  c++  java
  • react native仿企查查地区下拉

    只写了2级,三级同理

      {/*筛选地区*/}
                                <View style={[{backgroundColor: 'pink', height: 300, flexDirection: 'row',},]}>
                                    <View style={{ '40%'}}>
                          // 这里是一级地区(省) <ScrollView contentContainerStyle={{ '100%', backgroundColor: 'orange'}}> { area.map((val, i) => { return ( <TouchableWithoutFeedback onPress={() => this.clickArea(val, i)}>
                                      //这里的index是用来做选中后的样式 <View style={[{backgroundColor: this.state.index === i ? '#eee' : '#fff'}]}> <View style={{padding: 10, borderBottomColor: '#eee', borderBottomWidth: 1 / PixelRatio.get()}}> <Text style={{fontSize: 13, color: '#333'}}>{val.title}</Text> </View> </View> </TouchableWithoutFeedback> ) }) } </ScrollView> </View>                     // 这里是二级地区(市) <ScrollView> {
                            // 这里的this.state.index是点击一级地区的时候将其索引传给函数给state中的index赋值,索引这个index就是一级地区的索引 area[
    this.state.index].lists.map((item, k) => { return ( <TouchableWithoutFeedback onPress={() => this.secClickArea(item, k)}> <View style={{backgroundColor: '#eee'}}> <View style={[{padding: 8, borderBottomColor: '#fcfcfc', borderBottomWidth: 1 / PixelRatio.get()}, styles.flex]}> <Text style={{fontSize: 13, color: '#666'}}>{item}</Text> </View> </View> </TouchableWithoutFeedback> ) }) } </ScrollView>

                        // 三级可以写这里,然后点击二级的时候将二级点击的索引传给函数给state中的值,然后再放这里即可 </View>
  • 相关阅读:
    如何实现asp.net页面的美观性?
    关于UpdatePanel和页面刷新的问题
    由windows server2012 想起
    新手看SEO网站优化
    转载Web 2.0 新名词:Widget
    由“美图秀秀”软件的网站,看网站的生存模式
    关于团队合作的一点认识
    对新网好失望,郁闷中
    程序员度量:改善软件团队的分析学
    了解天才科学家的研究历程,了解知识贴近生活的一面,学习就是一件充满乐趣的事儿
  • 原文地址:https://www.cnblogs.com/lude1994/p/11102188.html
Copyright © 2011-2022 走看看