有人知道下面的代码有什么问题吗?因为当前我只能从数据库中获取1个数据,但是当数据库具有2个数据或3个数据时,它将显示以下错误消息:
JSON解析错误:无法解析JSON字符串
componentDidMount(){
const packid = 'this.props.navigation.getParam'('packid');
return fetch('http://xxx.xxx.x.xxx/User_Project/packages_List_klcc.php?packid='+packid, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
}
}).then((response) => response.json())
.then((responseJson) => {
console.log(responseJson)
this.setState({
isLoading: false,
dataklcc: responseJson
}, function() {
// In this block you can do something with new state.
});
})
.catch((error) => {
console.error(error);
});
}