You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.7 KiB
1.7 KiB
outline |
---|
deep |
Timer API Examples
本页是介绍@pear-rec/timer
插件的API
例子
本插件提供了计时器功能。
安装
import "@pear-rec/timer";
import "@pear-rec/timer/src/Timer/index.module.scss";
timer 计时器
效果展示
完整代码
import { useState } from "react";
import { useStopwatch } from "react-timer-hook";
import Timer from "@pear-rec/timer";
import "@pear-rec/timer/src/Timer/index.module.scss";
function App() {
const { seconds, minutes, hours, days, start, pause, reset } = useStopwatch({
autoStart: true,
});
const [isShowTitle] = useState(true);
return (
<div className="separator">
<h2>UseStopwatch Demo</h2>
<div className="timer">
<Timer
seconds={seconds}
minutes={minutes}
hours={hours}
days={days}
isShowTitle={isShowTitle}
/>
</div>
<div className="button" onClick={start}>
Start
</div>
<div className="button" onClick={pause}>
Pause
</div>
<div className="button" onClick={() => reset}>
Reset
</div>
</div>
);
}
export default App;