前端首屏优化
`//引入useDefer import {useDefer} from './useDefer'; const defer=useDefer()
//组件中使用
//useDefer.js import { ref } from 'vue'; export function useDefer(maxFrameCount = 1000) { const frameCount = ref(0); const refreshFrameCount = () => { requestAnimationFrame(() => { frameCount++; if (frameCount.value < maxFrameCount) { refreshFrameCount(); } }) } refreshFrameCount(); return function (showInFrameCount) { return frameCount.value >= showInFrameCount; } } `