Code Monkey home page Code Monkey logo

all-keep-alive's Introduction

all-keep-alive npm package

Features

一个升级版的keep-alive,可以用来缓存所有的页面,包括复用页面。 可以在实现一些多标签页面,打开标签需要缓存页面数据的场景下使用

install

npm install all-keep-alive

使用

import { allKeepAlive } from 'all-keep-alive'
export default {
  components: { allKeepAlive }
}

API跟vue自带的keep-alive组件一样

// 复用页面跳转的时候,路由不会跳转,所以需要在路由组件上添加一个key
// 需要把组件的路由地址传入到include数组中
// 例:localhost:8080/home/page3/3
// 需要把/home/page3/3作为参数push进include数组
<all-keep-alive :include="includePageNames">
  <router-view :key="$route.fullPath" />
</all-keep-alive>

例子

注意:这是vue2的版本

vue3正式版上周刚出,后续我再加个vue3的版本吧

欢迎大家star,提供issues。

License

LicenseFinder is released under the MIT License.

注意

为了使用方便,这里示例项目中的vuex直接读写了变量。正式的项目中,请使用mutation和action来控制vuex的值

all-keep-alive's People

Contributors

xiaowoxiaowo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.