一个非常简单、高度可定制的类似于 YouTube 的 React 加载器组件。
[![npm 下载][download-image]][download-url]
npm install --save react-top-loading-baryarn add react-top-loading-barhttps://unpkg.com/react-top-loading-barimport { useLoadingBar } from "react-top-loading-bar";
const App = () => {
const { start, complete } = useLoadingBar({
color: "blue",
height: 2,
});
return (
);
};import { LoadingBarContainer } from "react-top-loading-bar";
const Parent = () => {
return (
);
};import { useRef } from "react";
import LoadingBar, { LoadingBarRef } from "react-top-loading-bar";
const App = () => {
// prettier-ignore
const ref = useRef(null);
return (
);
};import { useState } from "react";
import LoadingBar from "react-top-loading-bar";
const App = () => {
const [progress, setProgress] = useState(0);
return (
);
};| 方法 | 参数 | 描述 |
|---|---|---|
| start(loaderType?) | continuous (默认) 或 static |
开始加载指示器。如果 type 为 "static", 它将启动静态条;否则, 它将启动动画连续条。 |
[download-image]: https://img.shields.io/npm/dm/react-top-loading-bar.svg [download-url]: https://npmjs.org/package/react-top-loading-bar Click here for demo
暂无开放 Issues,或尚未同步最近议题。