【发布时间】:2020-01-30 01:43:00
【问题描述】:
我从我的 API 中获取了这些数据。如何在文本输入中显示 name 属性的值?
[
{
"id": "1",
"userid": "",
"is_admin": "1",
"name": "Anshul Gupta",
"email": "testuser@gmail.com",
"company": "Kissui Metaliks and Steels Pvt. Ltd.",
"jobtitle": "Director",
"address": "366 and 368, MIE Part A, Bahadurgarh,Haryana,IndiaBahadurgarh, Haryana",
"cityid": "haryana",
"stateid": "Abohar",
...
}
]
【问题讨论】:
-
你到底是什么意思? yourArray[0]['name'] 返回名称!
-
从 api 获取此数据希望在 textinput 上呈现其值,如姓名、电子邮件等
-
请分享输入的区号!
-
构造函数(props) { super(props); this.state = { dataSource:[], } } async componentDidMount(){ try { AsyncStorage.getItem("user").then(async (user)=>{ const response = await fetch('myAPi=' + userData .id ); const responseJson = await response.json(); this.setState({ dataSource: responseJson, }) }) } }
标签: arrays reactjs react-native fetch