我将参数从一页传递到另一页。我还将一个链接 ( http://wwww.yahoo.com ) 与其他参数一起传递到结果页面。以下是我的源页面的代码:
<View style={styles.searchButton}>
<Button style={styles.searchButton}
title="Go to Details"
onPress={() => {
this.props.navigation.navigate('SearchSer', {
itemId: services[0].ser,
otherParam: services[0],
在下面的代码中,我试图通过读取参数将链接放入 TouchableOpacity。当我尝试打开链接时,我收到一条错误消息“JSON 解析错误”。以下是我的错误代码和屏幕截图:
<View>
<Text style={styles.Address1}> {JSON.stringify(otherParam["Phone"])}</Text>
<TouchableOpacity onPress={() => Linking.openURL(JSON.parse(JSON.stringify(otherParam["destURL"]))) }>
<Text style={styles.underLineText}>Distance and Directions</Text>
</TouchableOpacity>
</View>
destURL 是http://www.yahoo.com,它来自我的 JSON 文件。任何帮助将不胜感激。