Vue Router Layout is a lightweight utility designed for dynamically resolving layout components within Vue Router applications. Currently stable at version 0.4.1, the library provides a programmatic way to define layouts for routes by using a factory function, `createRouterLayout`, which then generates a `<RouterLayout>` component. This component is subsequently integrated into Vue Router's `routes` configuration. The package supports dynamic imports for layout components, enabling efficient code splitting. A key differentiator is its focus on minimalist layout resolution, allowing developers to specify layouts directly within their page components via a `layout` option, including passing props since v0.4.0. Its release cadence is irregular but consistent with bug fixes and features. Crucially, version 0.2.0 marked a breaking change by dropping Vue 2 support in favor of Vue 3, necessitating version awareness for project compatibility. For more comprehensive routing solutions, the author points to `vue-cli-plugin-auto-routing`.
npm install vue-router-layoutVerified import paths — ran on the pinned version, not inferred.
Initializes a `RouterLayout` component, configuring Vue Router to use it for dynamic layout resolution based on route meta or component options, demonstrating basic layout switching and prop passing.
Upgrade your project's Vue version to v3+, or downgrade `vue-router-layout` to a `0.1.x` release for Vue 2 compatibility.
Upgrade to `vue-router-layout@0.4.1` or newer to resolve the issue where the `created` hook is incorrectly triggered on layout changes.
Upgrade to `vue-router-layout@0.4.0` or newer to utilize the `layout.props` option for passing data to your layout components.
Ensure you are on `vue-router-layout@0.3.0` or later to benefit from improved handling of lazy component loading in router hooks and corrected lifecycle behavior, especially with async components.
Downgrade `vue-router-layout` to `0.1.x` for Vue 2 projects, or upgrade your entire project to Vue 3.
Augment Vue's `ComponentCustomOptions` interface to declare the `layout` property. For example: `declare module '@vue/runtime-core' { interface ComponentCustomOptions { layout?: string | { name: string; props?: Record<string, any> }; } }`Upgrade `vue-router-layout` to version `0.3.0` or higher, which includes significant improvements for handling lazy component loading and ensuring proper layout updates.