您好,我在使用react native组件链接在浏览器上显示某些内容时遇到问题,问题是当我从axios响应数据中获取价值时。
我的代码:
'use strict';
import React, {
Component
} from 'react';
import {
View,
BackHandler,
Platform,
StatusBar,
SafeAreaView,
ScrollView,
StyleSheet,
Image,
Text,
AsyncStorage,
TouchableOpacity,
TextInput,
Modal,
Linking,
WebView
} from 'react-native';
export default class Pay extends Component {
constructor(props){
super(props)
this.state = {
data: {}
}
}
getUrlPay(){
axios{
...
if(response.data == "success"){
this.setState({
data: response.data.data
})
}
}
}
render(){
return(
<TouchableOpacity onPress={() => Linking.openUrl(this.state.data.url)}>
<Text>OpenPay</Text>
</TouchableOpacity>
)
}
}
未定义错误不是对象
我的响应值为“ https://something.com”。
有解决方案吗?