【发布时间】:2021-07-04 15:40:40
【问题描述】:
我正在尝试控制台记录特定键的特定值,在这种情况下我只想控制台记录数字 54。
import React, {Component} from 'react';
import {Text, View} from 'react-native';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
data: [],
isLoading: true,
};
}
componentDidMount() {
const that = this;
fetch('http://10.0.2.2:8085/lastRoutineID/')
.then(function (response) {
return response.json();
})
// .then(function (jsonData) {
// return JSON.stringify(jsonData);
// })
.then(function (jsonStr) {
that.setState({data: jsonStr});
console.log('mount', jsonStr[0]);
});
}
render() {
console.log('json data ' + this.state.data);
return (
<View style={{flex: 1, padding: 24}}>
<Text>hi</Text>
</View>
);
}
}
[
{
lastIdRutina: 54
}
]
这是我在终端中得到的,我只想控制台记录这个数字
[Thu Apr 08 2021 11:54:27.566] LOG json data [object Object]
[Thu Apr 08 2021 11:54:27.574] LOG mount {"lastIdRutina": 54}
【问题讨论】:
标签: javascript node.js reactjs react-native api