Reactバックグラウンド管理システム-ホームコンポーネント
1. Homeコンポーネントは、ユーザーの総数、製品の総数、注文の総数を表示する必要があります。データリクエストバックエンドの/manage/statistic/base_count.doインターフェースは、
-
この .state = {
-
userCount: '-'、
-
productCount: '-'、
-
orderCount: '-'
-
}
-
//ページがマウントされた後にデータを要求します
-
componentDidMount(){
-
this .loadCount();
-
}
-
loadCount(){
- //バックエンドインターフェースをリクエストします
-
_statistic.getHomeCount()。then(res => {
-
this .setState(res);
-
}、errMsg => {
-
_mm.errorTips(errMsg);
-
});
-
}
2.データをページにレンダリングします
-
<div id = " page-wrapper ">
-
<PageTitle title = " ホーム " />
-
<div className = " 行 ">
-
<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>
-
</リンク>
-
</ 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>
-
</リンク>
-
</ 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>
-
</リンク>
-
</ div>
-
</ div>
-
</ div>
ON。投稿2020年4月16日夜07時53分 六、HC の読み取り(...)コメント(...) 編集 コレクション
1. Homeコンポーネントは、ユーザーの総数、製品の総数、注文の総数を表示する必要があります。データリクエストバックエンドの/manage/statistic/base_count.doインターフェースは、
-
この .state = {
-
userCount: '-'、
-
productCount: '-'、
-
orderCount: '-'
-
}
-
//ページがマウントされた後にデータを要求します
-
componentDidMount(){
-
this .loadCount();
-
}
-
loadCount(){
- //バックエンドインターフェースをリクエストします
-
_statistic.getHomeCount()。then(res => {
-
this .setState(res);
-
}、errMsg => {
-
_mm.errorTips(errMsg);
-
});
-
}
2.データをページにレンダリングします
-
<div id = " page-wrapper ">
-
<PageTitle title = " ホーム " />
-
<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>