onNuxtReady
onNuxtReady 可组合函数允许在应用初始化完成后运行回调。
onNuxtReady
仅在客户端运行。:br 它非常适合运行不会阻塞应用初始渲染的代码。plugins/ready.client.ts
export default defineNuxtPlugin(() => {
onNuxtReady(async () => {
const myAnalyticsLibrary = await import('my-big-analytics-library')
// do something with myAnalyticsLibrary
})
})
即使在应用初始化后运行,'safe' 也会运行。在这种情况下,代码将被注册以在下一个空闲回调中运行。
¥It is 'safe' to run even after your app has initialized. In this case, then the code will be registered to run in the next idle callback.