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