Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

vue-router-back-intercept

1.0.1 • Public • Published

vue-router-back-intercept

一个路由回退拦截的插件,因为vue-router没有提供对路由回退的监听,所以我就在路由拦截的基础上手撸了一个。

npm install vue-router-back-intercept --save

import vueRouterBackIntercept from 'vue-router-back-intercept';

Vue.use(vueRouterBack,{router,whiteList,name});

参数里router是必须的

whiteList和name是可选的

whiteList允许特定路由不加入回退逻辑,里面存放路由的name,如['home']

name允许使用者自定义标识页签的名称

需要用户手动增加拦截

this.$back.on("back", (to, from) => {

​ if (from.name === "home") {}

})

主动销毁所有拦截

this.$back.off()

获取路由栈的记录

this.$back.getRouteStack()

清除对路由栈的记录

this.$back.cleanRouteStack()

Install

npm i vue-router-back-intercept

DownloadsWeekly Downloads

7

Version

1.0.1

License

MIT

Unpacked Size

4.4 kB

Total Files

4

Last publish

Collaborators

  • avatar