1.5.0 • Published 4 years ago

@tobyas/vue-page-stack v1.5.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

vue-page-stack

npm version

English | 简体中文


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

Example

preview

demo code

Features

  • 🐉expanded on vue-router, the original navigation logic remains unchanged
  • ⚽When a page is re-rendered as a push or forward, the newly rendered page will be added to the Stack.
  • 🏆When back or go(negative number), the previous pages are not re-rendered, but instead are read from the Stack, and these pages retain the previous content state, such as the form content, the position of the scroll bar
  • 🏈back or go (negative) will remove unused pages from the Stack
  • 🎓replace will update the current page in the stack
  • 🎉activated hook function triggers when rolling back to the previous page
  • 🚀Browser back and forward events are supporded
  • 🍕Responding to changes in routes with Parameters is supporded, such as navigating from /user/foo to /user/bar, component instances are reused
  • 🐰provides routing direction changes, and you can add different animations when forward or backward

Installation and use

Installation

npm install vue-page-stack
# OR
yarn add vue-page-stack

use

import Vue from 'vue'
import VuePageStack from 'vue-page-stack';

// vue-router is necessary
Vue.use(VuePageStack, { router }); 
// App.vue
<template>
  <div id="app">
    <vue-page-stack>
      <router-view ></router-view>
    </vue-page-stack>
  </div>
</template>

CDN

<script src="https://unpkg.com/vue-page-stack/dist/vue-page-stack.umd.min.js"></script>
Vue.use(VuePageStack, { router });

API

install

use Vue.use to install vue-page-stack

Vue.use(VuePageStack, options);
// example
Vue.use(VuePageStack, { router });

Options description:

AttributeDescriptionTypeAccepted ValuesDefault
routervue-router instanceObjectvue-router instance-
nameVuePageStack nameString'VuePageStack''VuePageStack'
keyNamestack-key nameString'stack-key''stack-key'

you can customize VuePageStack's name and keyName

Vue.use(VuePageStack, { router, name: 'VuePageStack', keyName: 'stack-key' });

forward or backward

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

// App.vue
$route(to, from) {
  if (to.params['stack-key-dir'] === 'forward') {
    this.transitionName = 'forward';
  } else {
    this.transitionName = 'back';
  }
}

example

get current UI stack

let UIStack = this.$pageStack.getStack();

example code

Notes

keyName

Why is the parameter keyName added to the route? To support the browser's backward and forward events,this is important in webApp or wechat.

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):

1.5.0

4 years ago

1.4.40

4 years ago

1.4.41

4 years ago

1.4.39

4 years ago

1.4.38

4 years ago

1.4.37

4 years ago

1.4.36

4 years ago

1.4.35

4 years ago

1.4.33

4 years ago

1.4.34

4 years ago

1.4.32

4 years ago

1.4.28

4 years ago

1.4.31

4 years ago

1.4.30

4 years ago

1.4.24

4 years ago

1.4.26

4 years ago

1.4.25

4 years ago

1.4.27

4 years ago

1.4.23

4 years ago

1.4.20

4 years ago

1.4.22

4 years ago

1.4.21

4 years ago

1.4.19

4 years ago

1.4.18

4 years ago

1.4.17

4 years ago

1.4.15

4 years ago

1.4.16

4 years ago

1.4.9

4 years ago

1.4.11

4 years ago

1.4.8

4 years ago

1.4.10

4 years ago

1.4.13

4 years ago

1.4.12

4 years ago

1.4.14

4 years ago

1.4.7

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago