Javascript React本机ListItem图像url传递变量
我想将一些变量传递到我的头像图像url中,但这似乎不起作用:Javascript React本机ListItem图像url传递变量,javascript,reactjs,react-native,reactive-programming,Javascript,Reactjs,React Native,Reactive Programming,我想将一些变量传递到我的头像图像url中,但这似乎不起作用: renderItem = ({ item }) => ( <ListItem title= {item.name} subtitle={ <View style={styles.subtitleView}> <Text style={styles.ratingText}>Price: {item.price}</Text>
renderItem = ({ item }) => (
<ListItem
title= {item.name}
subtitle={
<View style={styles.subtitleView}>
<Text style={styles.ratingText}>Price: {item.price}</Text>
<Text style={styles.ratingText}>Stock: {item.stock}</Text>
</View>
}
avatar={{ uri: 'https://test.com/${item.ver}/${item.cid}.jpg',}}
/>
)
renderItem=({item})=>(
)
这是为了呈现我的
ListItem
,我需要这些变量为不同的项目获取不同的头像图片,但这对我不起作用。还有其他方法吗?这里是您的需求预览。ES6提供了一种新类型的字符串文字,使用反勾号作为分隔符。这些文本允许嵌入基本的字符串插值表达式,然后自动解析和计算这些表达式
let fb = "facebook";
<Image
source={{
uri: `https://${fb}.github.io/react-native/docs/assets/favicon.png`
}}
/>
let fb=“facebook”;
您需要使用反勾号而不是单引号:avatar={{uri:`{item.ver}/${item.cid}.jpg`,}}}}errm这意味着什么?单引号是这样的:“反勾号是这样的:`