ANTD倒计时不适用于特定日期
我正在尝试使用与ANTD React创建特定日期的组件。这是我的代码:
import { Statistic, Col, Row } from 'antd';
const { Countdown } = Statistic;
const deadline = Date.parse('2022-12-31') - Date.now();
const Count = () => {
return (
<Countdown title="Countdown" value={deadline} format="DD:HH:mm:ss"/>
)
}
倒计时仅显示00:00:00:00时间戳为正数时。任何帮助都将受到赞赏。谢谢!
I’m trying to create a component to a specific date using react with antd. Here's my code:
import { Statistic, Col, Row } from 'antd';
const { Countdown } = Statistic;
const deadline = Date.parse('2022-12-31') - Date.now();
const Count = () => {
return (
<Countdown title="Countdown" value={deadline} format="DD:HH:mm:ss"/>
)
}
The countdown just displays 00:00:00:00 when the timestamp has is a positive number. Any help is appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
截止日期传递给了
&lt; countdown&gt;
组件必须是绝对值(从时代开始 - 1970年1月1日)。因此,您需要仅将其更改为:
您可以检查此 stackblitz 参考示例。
The deadline passed to the
<Countdown>
component must be an absolute value (that is starting from epoch - Jan 1, 1970).So you need to change it simply to:
You can check this Stackblitz example for reference.