github https://github.com/mattboldt/typed.js
在线案例 https://mattboldt.com/demos/typed-js
typed.js 配置参考 https://github.com/mattboldt/typed.js/#customization
import Typed from 'typed.js';
function App() {
const domRef = useRef(null);
useEffect(() => {
const typed = new Typed(domRef.current, {
strings: ["秦孝公", "秦始皇", '汉武帝', '光武帝'],
typeSpeed: 100,
loop: true,
loopCount: Infinity,
});
return () => {
typed.destroy();
};
}, []);
return (
<div ref={domRef} />
)
}