繁体   English   中英

undefined-is-not-an-object-evaluating-this-state-datasource.map

[英]undefined-is-not-an-object-evaluating-this-state-datasource.map

componentDidMount(){
    fetch('https://boboboi.online/c_api_sales/get_dest',{
      method: 'POST',
            headers: {
                Accept: 'application/json',
                'Content-Type': 'application/json',
              },
                body: JSON.stringify({
                        port_code: 'CP-002',
                        api_key: 'ae9a6ce9a7479038d998060ef6d65ca9f86a13ed962a5366b3b0662cc52dde1b',
                        token: 'a959190d43520f8017ed2ca09ffc61bb'
                }),
    })   
        .then((response) => response.json())
        .then((responseJson) => { 
            this.setState({
                isLoading: false,
                dataSource: responseJson
              }, function() {
                // In this block you can do something with new state.
              });
            })
            .catch((error) => {
              console.error(error);
            });
        }

        GetPickerSelectedItemValue=()=>{

            Alert.alert(this.state.PickerValueHolder);

          }

看法在此处输入图片说明

map() 方法可以用于数组而不是对象。 所以如果你想使用 map 方法,你可以尝试像 Object.keys(this.state.dataSource).map((key, index)=> { //your function and logic });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM