react jquery方式获取api数据接口
2021-02-09 04:25
标签:jquer amount err com mock turn body ror his react jquery方式获取api数据接口 标签:jquer amount err com mock turn body ror his 原文地址:https://www.cnblogs.com/sunbey/p/8568204.htmlimport React, { Component } from ‘react‘;
import Record from ‘./Record‘;
import { getJSON } from ‘jquery‘;
class Records extends Component {
constructor() {
super();
this.state = {
error: null,
isLoaded: false,
records: []
};
}
componentDidMount() {
getJSON(‘https://5aa780cb7f6fcb0014ee24aa.mockapi.io/api/v1/records‘).then(
res => {
this.setState({
isLoaded: true,
records: res
});
},
error => {
this.setState({
isLoaded: true,
error
})
}
)
}
render() {
const { error, isLoaded, records } = this.state;
if (error) {
return
Records
{records.map((record) => Date
Title
Amount
上一篇:python导入第三方库
文章标题:react jquery方式获取api数据接口
文章链接:http://soscw.com/index.php/essay/52926.html