Routing and navigation for your Vue SPA. Vue3.0 单页应用导航管理器
vue-page-stack currently targets Vue 3. For the Vue 2 version, see v1.5.0.
English | 简体中文
A Vue 3 SPA navigation stack that preserves route state in stack order, so back navigation feels closer to a native app than a full page remount.
vue-router without changing your route definitionspush and forwardback and go(-n) so local UI state can survivereplaceback and forward events for direction-aware transitionsVuePageStack manages pages in navigation order instead of providing include, exclude, or maxKeepAlive keeps previously cached pages around until they are evicted; VuePageStack trims pages that are no longer reachable in the stackpnpm install vue-page-stackimport { createApp } from 'vue';
import { VuePageStackPlugin } from 'vue-page-stack';
const app = createApp(App);
app.use(VuePageStackPlugin, { router });
Use a stable route key on the rendered route component. In most apps, $route.fullPath is the safest default because it treats different params and query strings as distinct stack entries.
Use app.use to install vue-page-stack.
import { VuePageStackPlugin } from 'vue-page-stack';
//...
app.use(VuePageStackPlugin, { router });Options:
| Attribute | Description | Type | Accepted Values | Default |
|---|---|---|---|---|
router |
vue-router instance |
Router |
router created by createRouter |
required |
Use the back and forward events to react to navigation direction changes.
pnpm install
pnpm run build
pnpm run lint
pnpm run test:run
pnpm run test:coveragedist/ is treated as a release artifact and is generated automatically by npm pack / npm publish through the prepack script, so it does not need to stay checked in during normal development.
Release-by-release changes are documented in the release notes.
The page instance management model is inspired by Vue's KeepAlive implementation.
This plugin draws on both vue-navigation and vue-nav. Thanks for the inspiration.
Thanks goes to these wonderful people (emoji key):
hezf
李娜
余小磊
yellowbeee
No open issues yet, or sync has not completed.