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 渲染布局之前(即在插件或路由中间件中)完成此操作,以避免水合不匹配。