This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
只需将'替换为````$ {item} - $ {index},以便将变量插入字符串中。但是实际上,您只需要参考索引如下:
$ {item} - $ {index}
return ( <View style={styles.container}> <FlatList data={tabs} keyExtractor={(_, index) => index.toString()} renderItem={({ item }) => { return ( <TouchableOpacity style={styles.pill} onPress={() => { setSelectedTab(item); }}> <Text style={styles.pillText}>{item}</Text> </TouchableOpacity> ) }} /> <LinearGradient colors={['gold', '#FF7F50', '#FF7F50']} style={StyleSheet.absoluteFill}> <Text style={styles.title}>Main Menu Screen</Text> <Text style={styles.title}>{ address }</Text> </LinearGradient> </View> ); };
Just replace '' by `` around ${item}-${index} in order to interpolate your variables in the string. But in fact you only need to refer to the index as follows :
${item}-${index}
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
只需将'替换为````
$ {item} - $ {index}
,以便将变量插入字符串中。但是实际上,您只需要参考索引如下:Just replace '' by `` around
${item}-${index}
in order to interpolate your variables in the string. But in fact you only need to refer to the index as follows :