包装:@tsparticles/react
tsParticles 的官方 React 包装器。
安装
bash
pnpm add @tsparticles/react @tsparticles/engine @tsparticles/slim快速设置流程
- 安装wrapper+engine+loader包。
- 将
ParticlesProvider放置在应用根目录(例如main.tsx或layout.tsx)——它只需在整个应用生命周期内渲染一次。 - 使用
ParticlesProvider和loadSlim初始化一次。 - 使用类型化选项渲染
Particles组件。
Monorepo 参考资料
- 包文件夹:https://github.com/tsparticles/tsparticles/tree/main/wrappers/react
- 演示应用程序:https://github.com/tsparticles/tsparticles/tree/main/demo/react
