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

uni-vant-router

v1.0.4

Published

基于 uniapp 的路由

Readme

uni-vant-router

介绍

uni-vant-router 是基于 uni-app 的路由封装,基于 uni-app 的路由封装。支持 H5 和微信小程序

安装

pnpm add -S uni-vant-router

创建路由实例

import { createRouter } from 'uni-vant-router'

export const router = createRouter({
  routes: [
    { 
      path: '/pages/index/index',
      meta: {}
    }
  ],
})

注册路由

import { createSSRApp } from 'vue'
import App from './App.vue'
import { router } from '@/router'

export function createApp() {
  const app = createSSRApp(App)

  app.use(router)

  return {
    app,
  }
}

编程式导航

pathquery 参数外,其他参数同 uni-app 的导航方法。

注:path 参数优先于 url 参数

import { useRouter } from 'uni-vant-router'

const router = useRouter()

router.navigateTo({ path: '', query: {} })

router.redirectTo({ path: '', query: {} })

router.navigateBack({ delta: 1 })

router.reLaunch({ path: '', query: {} })

router.switchTab({ path: '', query: {} })

在 web-view 中使用

import { useRouter } from 'uni-vant-router'

const router = useRouter()

// 从 H5 跳转小程序页面,其他导航类型同上,只增加了 engine 参数
router.navigateTo({ path: '', query: {}, engine: wx.miniProgram })

导航守卫

const router = createRouter({ ... })

// 全局前置守卫
router.beforeEach((to, from, next)=>{
  
  // next 支持使用 openType 指定跳转类型,支持:navigateTo、redirectTo、reLaunch、switchTab,默认为 navigateTo
  next()
})

// 全局后置守卫
router.afterEach((to, from)=>{
  console.log('to:', to)
  console.log('from:', from)
})

启动拦截

修改 App.vue

import { useRouter } from 'uni-vant-router'
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'

const router = useRouter()

onLaunch((options)=>{
  // 冷启动拦截
  router.launch(options)
})

onShow((options)=>{
  // 热启动拦截
  router.hotLaunch()
})

onHide(()=>{
  // 一定要添加这一行,否则无法触发热启动
  router.unload()
})

tabbar 对应的页面上添加监听,如果不添加,切换 tab 时无法执行路由拦截,即 beforeEach

import { useRouter } from 'uni-vant-router'
import { onShow } from '@dcloudio/uni-app'

const router = useRouter()

onShow(()=>{
  router.tabItemShow()
})

虽然 uni-vant-router 支持热启动,但是由于 uni-app 的限制,在热启动时无法拦截页面中发送的请求,因此需要在对应页面中单独处理。