setPageLayout

源文件
setPageLayout 允许你动态改变页面布局。
setPageLayout 允许你动态改变页面布局。它依赖于对 Nuxt 上下文的访问,因此只能在 Nuxt 上下文中调用。
app/middleware/custom-layout.ts
export default defineNuxtRouteMiddleware((to) => {
  // Set the layout on the route you are navigating _to_
  setPageLayout('other')
})
如果你选择在服务器端动态设置布局,你必须在 Vue 渲染布局之前(即在插件或路由中间件中)完成,以避免水合不匹配。