Home

Awesome

vue-page-stack

<p align="center"> <img src="https://raw.githubusercontent.com/hezhongfeng/images/master/stack.svg" width="200"> </p> <p align="center"> <a href="https://www.npmjs.com/package/vue-page-stack"> <img src="https://img.shields.io/npm/dt/vue-page-stack.svg" alt="Downloads"> </a> <a href="https://www.npmjs.com/package/vue-page-stack"> <img src="https://img.shields.io/npm/dm/vue-page-stack.svg" alt="Downloads"> </a> <br> <a href="https://github.com/hezhongfeng/vue-page-stack/blob/master/LICENSE.md"> <img src="https://img.shields.io/npm/l/vue-page-stack.svg" alt="License"> </a> <a href="https://www.npmjs.com/package/vue-page-stack"> <img src="https://img.shields.io/npm/v/vue-page-stack.svg" alt="Version"> </a> </p>

v3.2.0

  1. FIx the bug of router.go

v3.1.4

  1. FIx the bug of refreshing the browser and then going back

v3.1.3

  1. Fixed the page caching issue when using replace.

v3.1.2

  1. Removed the stack-key parameter from the URL.
  2. Due to special handling of built-in components in Vue3.x, it is currently not possible to use it together with Transition.

This is the version of Vue3.0, Vue2.0 please click this link

English | 简体中文


A Vue3 SPA navigation manager,cache the UI in the SPA like a native application, rather than destroy it.

<div align="center"> <img src="https://raw.githubusercontent.com/hezhongfeng/images/master/vue-page-stack.gif"> </div>

Example

preview

demo code

Features

The difference between VuePageStack and KeepAlive

Installation and use

Installation

pnpm install vue-page-stack

use

import { createApp } from 'vue';
import { VuePageStackPlugin } from 'vue-page-stack';

const app = createApp(App);

// router is necessary
app.use(VuePageStackPlugin, { router });
// App.vue
<template>
  <router-view v-slot="{ Component }">
    <vue-page-stack @back="onBack" @forward="onForward">
      <component :is="Component" :key="$route.fullPath"></component>
    </vue-page-stack>
  </router-view>
</template>

<script setup>
const onBack = () => {
  console.log('back');
};

const onForward = () => {
  console.log('forward');
};
</script>

API

install

use Vue.use to install vue-page-stack

import { VuePageStackPlugin } from 'vue-page-stack';

//...
app.use(VuePageStackPlugin, { router });

Options description:

AttributeDescriptionTypeAccepted ValuesDefault
routervue-router instanceObjectvue-router instance-
nameVuePageStack nameString'VuePageStack''VuePageStack'

forward or back

If you want to make some animate entering or leaving, vue-page-stack offers stack-key-dir to judge forward or backward.

// App.vue
<vue-page-stack @back="onBack" @forward="onForward">
  <component :is="Component" :key="$route.fullPath"></component>
</vue-page-stack>

example

Notes

Changelog

Details changes for each release are documented in the release notes.

Principle

Getting the current page instance refers to the keep-alive section of Vue.

Thanks

The plug-in draws on both vue-navigation and vue-nav,Thank you very much for their inspiration.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

<table> <tr> <td align="center"><a href="http://hezf.online"><img src="https://avatars2.githubusercontent.com/u/12163050?v=4" width="100px;" alt="hezf"/><br /><sub><b>hezf</b></sub></a><br /><a href="#design-hezhongfeng" title="Design">🎨</a></td> <td align="center"><a href="https://github.com/woshilina"><img src="https://avatars0.githubusercontent.com/u/28744945?v=4" width="100px;" alt="李娜"/><br /><sub><b>李娜</b></sub></a><br /><a href="https://github.com/hezhongfeng/vue-page-stack/commits?author=woshilina" title="Documentation">📖</a></td> <td align="center"><a href="https://github.com/yuxiaolei1989"><img src="https://avatars0.githubusercontent.com/u/7732447?v=4" width="100px;" alt="余小磊"/><br /><sub><b>余小磊</b></sub></a><br /><a href="https://github.com/hezhongfeng/vue-page-stack/commits?author=yuxiaolei1989" title="Code">💻</a></td> <td align="center"><a href="https://github.com/yellowbeee"><img src="https://avatars0.githubusercontent.com/u/16685984?v=4" width="100px;" alt="yellowbeee"/><br /><sub><b>yellowbeee</b></sub></a><br /><a href="https://github.com/hezhongfeng/vue-page-stack/commits?author=yellowbeee" title="Code">💻</a></td> </tr> </table>