3.10 工程代码同步master

This commit is contained in:
jl-zhoujl2
2022-03-10 14:24:13 +08:00
parent 41ab55a4ac
commit 62f6b07ee2
914 changed files with 143121 additions and 29110 deletions

View File

@ -0,0 +1,38 @@
function FormattedDate(props) {
return <div style={{color:"#FFFFFF"}}><div>当前{props.date.toLocaleDateString()}</div>
<div>{props.date.toLocaleTimeString()}</div>
</div>;
}
export default class Datetime extends React.Component {
constructor(props) {
super(props);
this.state = { date: new Date() };
}
// 组件挂载完成之后启动定时器
componentDidMount() {
this.timeID = setInterval(() => this.tick(), 1000);
}
// 组件卸载之前清除定时器
//(注:这是我们用这个钩子函数经常做的一件事)
componentWillUnmount() {
clearInterval(this.timeID);
}
// 定义一个tick方法专门用于调用setState方法修改date
tick() {
this.setState({
date: new Date(),
});
}
render() {
const { className }=this.props;
return (
<div className={className}>
<FormattedDate date={this.state.date} />
</div>
);
}
}