/*! For license information please see 1515.3b17635b.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["1515"],{57307:function(s,n,a){"use strict";a.r(n);var l=a("80681");let t=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,l.wg)(),(0,l.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
\u63D0\u4F9B\u4FBF\u6377\u7684 requestAnimationFrame \u7684\u8C03\u7528\u548C\u53D6\u6D88\u3002
\n\u901A\u8FC7 useRaf
\u65B9\u6CD5\uFF0C\u53EF\u4EE5\u5728\u4E0B\u4E00\u6B21\u6D4F\u89C8\u5668\u91CD\u65B0\u7ED8\u5236\u4E4B\u524D\u8C03\u7528\u6307\u5B9A\u7684\u51FD\u6570\u3002
import { useRaf } from '@vant/use';\n\nexport default {\n setup() {\n let count = 0;\n useRaf(() => {\n console.log(++count); // \u53EA\u4F1A\u6267\u884C 1 \u6B21\n });\n },\n};\n
\n\u901A\u8FC7\u5F00\u542F isLoop
\u9009\u9879\uFF0C\u4F60\u53EF\u4EE5\u6309\u6307\u5B9A\u7684\u95F4\u9694\u91CD\u590D\u6267\u884C\u67D0\u4E2A\u51FD\u6570\uFF0C\u76F4\u5230\u88AB\u53D6\u6D88\u3002
import { useRaf } from '@vant/use';\n\nexport default {\n setup() {\n let count = 0;\n const cancelRaf = useRaf(\n () => {\n console.log(++count); // \u65E0\u9650\u6267\u884C\uFF0C\u76F4\u5230\u88AB cancel\n\n if (count === 5) {\n cancelRaf();\n }\n },\n {\n isLoop: true, // \u5F00\u542F\u5FAA\u73AF\n interval: 100, // \u8BBE\u7F6E\u8C03\u7528\u95F4\u9694\n },\n );\n },\n};\n
\nfunction useRaf(\n callback: () => void,\n options: {\n interval?: number;\n isLoop?: boolean;\n },\n): void;\n
\n\u53C2\u6570 | \n\u8BF4\u660E | \n\u7C7B\u578B | \n\u9ED8\u8BA4 | \n
---|---|---|---|
callback | \n\u56DE\u8C03\u51FD\u6570 | \n() => void | \n- | \n
options | \n\u914D\u7F6E\u53C2\u6570 | \n{ interval?: number; isLoop?: boolean } | \n{ interval: 0; isLoop: false } | \n