setPageLayout

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