React background management system-Home component
1. The Home component needs to display the total number of users, the total number of products and the total number of orders. The data request backend's /manage/statistic/base_count.do interface returns the
-
this.state = {
-
userCount : '-',
-
productCount : '-',
-
orderCount : '-'
-
}
-
// Request data after the page is mounted
-
componentDidMount(){
-
this.loadCount();
-
}
-
loadCount(){
- // Request the backend interface
-
_statistic.getHomeCount().then(res => {
-
this.setState(res);
-
}, errMsg => {
-
_mm.errorTips(errMsg);
-
});
-
}
2. Render the data to the page
-
<div id="page-wrapper">
-
<PageTitle title = " Home " />
-
<div className="row">
-
<div className="col-md-4">
-
<Link to="/user" className="color-box brown">
-
<p className="count">{this.state.userCount}</p>
-
<p className="desc">
-
<i className="fa fa-user-o"></i>
-
<span> Total users </ span>
-
</p>
-
</Link>
-
</div>
-
<div className="col-md-4">
-
<Link to="/product" className="color-box green">
-
<p className="count">{this.state.productCount}</p>
-
<p className="desc">
-
<i className="fa fa-list"></i>
-
<span> Total items </ span>
-
</p>
-
</Link>
-
</div>
-
<div className="col-md-4">
-
<Link to="/order" className="color-box blue">
-
<p className="count">{this.state.orderCount}</p>
-
<p className="desc">
-
<i className="fa fa-check-square-o"></i>
-
<span> Total orders </ span>
-
</p>
-
</Link>
-
</div>
-
</div>
-
</div>
ON. Posted 2020-04-16 19:53 Six, hc read ( ... ) Comments ( ... ) edit collections
1. The Home component needs to display the total number of users, the total number of products and the total number of orders. The data request backend's /manage/statistic/base_count.do interface returns the
-
this.state = {
-
userCount : '-',
-
productCount : '-',
-
orderCount : '-'
-
}
-
// Request data after the page is mounted
-
componentDidMount(){
-
this.loadCount();
-
}
-
loadCount(){
- // Request the backend interface
-
_statistic.getHomeCount().then(res => {
-
this.setState(res);
-
}, errMsg => {
-
_mm.errorTips(errMsg);
-
});
-
}
2. Render the data to the page
-
<div id="page-wrapper">
-
<PageTitle title = " Home " />
-
<div className="row">
-
<div className="col-md-4">
-
<Link to="/user" className="color-box brown">
-
<p className="count">{this.state.userCount}</p>
-
<p className="desc">
-
<i className="fa fa-user-o"></i>
-
<span>用户总数</span>
-
</p>
-
</Link>
-
</div>
-
<div className="col-md-4">
-
<Link to="/product" className="color-box green">
-
<p className="count">{this.state.productCount}</p>
-
<p className="desc">
-
<i className="fa fa-list"></i>
-
<span>商品总数</span>
-
</p>
-
</Link>
-
</div>
-
<div className="col-md-4">
-
<Link to="/order" className="color-box blue">
-
<p className="count">{this.state.orderCount}</p>
-
<p className="desc">
-
<i className="fa fa-check-square-o"></i>
-
<span>订单总数</span>
-
</p>
-
</Link>
-
</div>
-
</div>
-
</div>