在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ 用axios在接口獲取到的數(shù)據(jù)如何添加到react中?

用axios在接口獲取到的數(shù)據(jù)如何添加到react中?

1.用axios獲取接口中的數(shù)據(jù),想將數(shù)據(jù)添加到render中的span標(biāo)簽內(nèi),如何添加?
2.axios.get('', {

        timeout: 1000,
    })
        .then(function (response) {
            var lists=response.data.data;
            var problem=lists.ASK_CONTENT;
            console.log(problem);
        })
        .catch(function (error) {
            console.log(11111);
        });
        
        

render() {

    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
        labelCol: { span: 6 },
        wrapperCol: { span: 14 },
    };
    return (
        <Form onSubmit={this.handleSubmit}>
            <FormItem
                {...formItemLayout}
                label="問(wèn)題:"
                className="problems"
            >
                <span className="ant-form-text wenti">將problem的值添加至此</span>
            </FormItem>

3.
clipboard.png

clipboard.png

回答
編輯回答
九年囚

應(yīng)該有個(gè)state管理器吧,比如redux、mobx等。
獲取到的數(shù)據(jù)直接setState就好了。
推薦dva

2018年6月14日 08:23