tuns-mobile-components
Version:
Tuns Design UI
43 lines (33 loc) • 941 B
JavaScript
import React from "react";
import { connect } from "dva";
import { List, Button } from "antd-mobile";
import moment from "moment";
import styles from "./index.less";
const { Item } = List;
(store => ({ asyncData: store.demoAsync }))
class index extends React.Component {
getNameList = () => {
const { dispatch } = this.props;
dispatch({ type: "demoAsync/getNameList" });
};
render() {
const { asyncData } = this.props;
const { namelist } = asyncData;
return (
<div className={styles.root}>
<List className={styles.list}>
<Item>
{moment("2019-12-06 12:00:00")
.toDate()
.toString()}
</Item>
{namelist.map(item => (
<Item key={item.id}>{item.name}</Item>
))}
</List>
<Button onClick={this.getNameList}>获取异步数据</Button>
</div>
);
}
}
export default index;