map遍历

作者: 冷洪林 | 来源:发表于2016-12-21 10:48 被阅读74次
    • 用法
    var names = ['Alice', 'Emily', 'Kate'];
    names.map(function (name) {
          return <div>Hello, {name}!</div>
    })
    
    • 如果是前面调用了map遍历方法,则需将map返回
    // cell的下半部分
        renderCellBottomView(rowData){
            return rowData.map((item, index) => {
                return(
                        <View style={styles.cellBottomStyle_goods} key={index}>
                            <TouchableOpacity
                                onPress={() => {alert("点击了商品")}}>
                                <View style={styles.goodsImgStyle}>
                                    <Image
                                        style={{width:85, height:61}}
                                        source={{uri: item.picurl}}/>        
                                </View>
                            </TouchableOpacity>    
                            <View style={{width:85, height:9.5, marginTop:5, alignItems:"center"}}>
                                <Text style={{color:"#F96547", fontSize:Size(14)}}>¥{item.price}</Text>
                            </View>
                        </View>
                )
            })
        }
    

    相关文章

      网友评论

          本文标题:map遍历

          本文链接:https://www.haomeiwen.com/subject/ulszmttx.html