npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-route-manager

v2.0.3

Published

记录每次跳转的`vue-route name`, 内置了一些处理回退的方法, 方便回退到**指定页面**

Readme

路由管理器

记录每次跳转的vue-route name, 内置了一些处理回退的方法, 方便回退到指定页面

背景

笔者所开发的项目中经常遇到各种花式跳转, 例如从引导页的选择操作到最后的提交审核中间会经过无数页面, 甚至中间所做的操作不同也会导致最后回退深度不同

假设项目中 起始点都是选择页, 最终都会抵达提交页 并且都会返回到最初的页面(选择页)

选择页 --> B --> C --> 提交页
情况一 从选择到提交 中间经历了 B、C, 这时候返回 A 需要调用router.go(-3)
----------------------------------------

选择页 --> B-1 ------> 提交页
情况二 从选择到提交 只经历了 B-1 , 这时候 go(-3) 不再适用, 此时可能会增加查询参数(渠道id)来区分第二种情况
----------------------------------------

选择页 --> B-2 --> C-2 -->C-2-1 --> 提交页
这种情况 又会发现不仅 go(-3) 不适用, 查询参数还得多加一种类型, 如果后续还需要区分更多渠道, 可想而知啊...

此时可以使用RouteManager插件来处理这一系列复杂的问题

入门

npm i vue-route-manager -S
import Vue from 'vue'

// 引入 路由管理器
import VueRouteManager from 'vue-route-manager'

// 并将其挂载到 Vue 上
Vue.use(VueRouteManager, { /* ...ManagerOptions */ })

// 使用 v-cache-route-stack 将 router-view 包裹
<v-cache-route-stack>
  <router-view />
</v-cache-route-stack>
// 此时在页面中可以用 this.$RouteManager 来访问管理器

ManagerOptions参数说明

| 参数名 | 类型 | 必须 | 描述 | | ------ | ----------- | ---- | --------------- | | router | VueRouter | Y | VueRouter对象 | | debug | Boolean | N | 是否开启调试 |

示例

Home 页

路由信息 { path: '/home', name: 'home', component: Home }

<template>
	<button @click="jump">下一页</button>
</template>
<script>
exprot default {
   methods: {
      jump(){
         // 记录首页的 name
         this.$RouteManager.setMark('home')
         this.$router.push({ name: 'page-1' })
      }
   }
}
</script>

Page-1 页

路由信息 { path: '/page_1', name: 'page-1', component: Page-1 }

<template>
	<div class="page-1">
		page-1
		<button @click="$router.push({ name: 'page-2' })">下一页</button>
		<button @click="$router.replace({ name: 'page-1' })">重定向</button>
	</div>
</template>

Page-2 页

路由信息 { path: '/page_2', name: 'page-2', component: Page-2 }

<template>
	<div class="page-2">
		page-2
		<button @click="$router.push({ name: 'page-3' })">下一页</button>
		<button @click="backToHome">返回首页</button>
	</div>
</template>
<script>
exprot default {
   methods: {
      backToHome(){
         // 调用 toMark 来返回到最开始记录的 home 页
         this.$RouteManager.toMark()
      }
   }
}
</script>

Page-3 页

路由信息 { path: '/page_3', name: 'page-3', component: Page-3 }

<template>
  <div class="page-3">
    page-3
    <button @click="backToHome">返回首页</button>
    <button @click="backToPage">返回 page-1</button>
  </div>
</template>
<script>
exprot default {
   methods: {
      backToPage(){
         // 调用 backToRoute 来返回到指定页(必须经历过此页面)
         this.$RouteManager.backToRoute('page-1')
      },
		backToHome(){
         // 调用 toMark 来返回到最开始记录的 home 页
         this.$RouteManager.toMark()
      }
   }
}
</script>

解决问题

A --> B --> C --> D --返回-> A // 情况一
 |--> B-1 ------> D --返回-> A // 情况二
 |--> B-2 --> C-2 -->C-2-1 --> D --返回-> A // 情况三

首先在A页面调用this.$RouteManager.setMark('page-A')或者this.$RouteManager.setMark()

接着B页面需要返回的时候调用this.$RouteManager.toMark()即可

Methods

setMark([mark])

  • mark
    • Type: String
    • mark所指路由列表当中的 fullPath|name this.$route.fullPath || this.$route.name
    • Default: 当前路由的 fullPath

设定路线标记

toMark()

返回到标记点, 通过setMark来设置mark

backToRoute(route)

  • route
    • Type: String | RoutePops
    • route所指路由列表当中的 this.$route
    • RoutePops.name:this.$route.name
    • RoutePops.path:this.$route.fullPath

回退到指定路线