第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

反應(yīng)this.setState不是一個(gè)函數(shù)

反應(yīng)this.setState不是一個(gè)函數(shù)

MMTTMM 2019-09-20 14:55:17
我是React的新手,我正在嘗試編寫一個(gè)使用API的應(yīng)用程序。我一直收到這個(gè)錯(cuò)誤:TypeError:this.setState不是函數(shù)當(dāng)我嘗試處理API響應(yīng)時(shí)。我懷疑這個(gè)綁定有問題,但我無法弄清楚如何修復(fù)它。這是我的組件的代碼:var AppMain = React.createClass({    getInitialState: function() {        return{            FirstName: " "        };    },    componentDidMount:function(){        VK.init(function(){            console.info("API initialisation successful");            VK.api('users.get',{fields: 'photo_50'},function(data){                if(data.response){                    this.setState({ //the error happens here                        FirstName: data.response[0].first_name                    });                    console.info(this.state.FirstName);                }            });        }, function(){        console.info("API initialisation failed");        }, '5.34');    },    render:function(){        return (            <div className="appMain">            <Header  />            </div>        );    }});
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 938 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)