【发布时间】:2018-02-13 19:26:38
【问题描述】:
我是 react.js 的新手,我正在尝试在表格中以 JSON 格式显示数据。所以我做的是:
import React from 'react';
import axios from 'axios';
class TableUser extends React.Component {
constructor(props) {
super(props);
this.state = {
libelle_produit: ''
};
}
componentDidMount(){
axios
.get('admin/prdtId/')
.then(({ data })=> {
this.setState({
libelle_produit: data.libelle_produit
});
})
.catch((err)=> {})
}
render() {
return <div>
<p>{ this.state.libelle_produit }</p>
</div>;
}
}
export default TableUser;
我希望能够访问每个组件的 libelle 产品并将其打印在网站上
[{"libelle_produit":"测试产品"}]
谢谢
【问题讨论】:
-
你能分享一下
data.libelle_produit目前返回的内容吗? -
恢复是什么意思?
-
recover= recuperate recuerate libelle_produit from this format json [{"libelle_produit":"test produit"}]
标签: json reactjs parsing axios