【发布时间】:2021-02-14 10:12:48
【问题描述】:
import React, { Component } from "react";
import axios from "axios";
class Verifry extends Component {
constructor(props) {
super(props);
this.state = {
s: "0",
user: [],
};
}
/* 具有标题作为 res.data 中的属性*/
异步组件DidMount() {
等待 axios
.get(http://10.0.0.106:8080/kuwait_elections/api/about_us)
.then((res) => {
常人 = res.data;
this.setState({用户:persons.data.title,s:“4”});
控制台.log(this.state.user);
});
}
组件DidUpdate() {
// this.state.user.map((u) => {
// 返回
-
{this.state.user.map((t) => {
返回
- {t.title} ; })}
export default Verifry;
【问题讨论】:
-
你能格式化你的代码sn-p吗?