preloadComponents
Nuxt 提供了一些实用程序,让你可以控制组件的预加载。
预加载组件会加载页面即将需要的组件,这些组件你希望在渲染生命周期的早期就开始加载。这确保了它们可以更早地使用,并且不太可能阻塞页面渲染,从而提高性能。
¥Preloading components loads components that your page will need very soon, which you want to start loading early in rendering lifecycle. This ensures they are available earlier and are less likely to block the page's render, improving performance.
使用 preloadComponents
手动预加载已在 Nuxt 应用中全局注册的单个组件。默认情况下,Nuxt 将这些文件注册为异步组件。你必须使用 Pascal 大小写的组件名称。
¥Use preloadComponents
to manually preload individual components that have been registered globally in your Nuxt app. By default Nuxt registers these as async components. You must use the Pascal-cased version of the component name.
await preloadComponents('MyGlobalComponent')
await preloadComponents(['MyGlobalComponent1', 'MyGlobalComponent2'])
在服务器上,
preloadComponents
将不起作用。