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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue-router-paths

v1.1.0

Published

扩展meta对象,支持一些常用功能

Downloads

13

Readme

vue-router-paths

扩展meta对象,支持一些常用功能

  • 面包屑,当前路径
  • 子菜单数据获取

使用

import watchRouterPaths from 'vue-router-paths'

const router = new VueRouter({
  mode: 'history',
  base: '/',
  routes: [{
      path: '/',
      component: Hello,
      meta: {
        title: '首页',
    },
    children: [
      {
        path: '/profile',
        component: Profile,
        meta: {
          title: '个人中心'
        },
        children: [
          {path:'setting', meta:{title:'设置'}},
          {path:'avatar', meta:{title:'头像'}},
          {path:'address', meta:{title:'收货地址'}},
        ]
      },
    ]
    }, // No props, no nothing
    {
      path: '/hello/a',
      component: Hello,
      props: true,
      meta: {
        title: 'hello'
      },
      children: [{
        path: '/hello/sub/:name',
        component: Hello,
        props: true,
        meta: {
          title: 'hello2'
        }
      }]
    },
    {
      path:'/user',
      redirect:'/profile',
      meta: {
        title: '个人中心'
      },
    },
  ]
})
watchRouterPaths(router)

preview

router.routes

router.routes = router.options.routes

meta 对象

  • @param {string} index 当前数组索引
  • @param {bool} display true 显示 false 不显示 默认不显示
  • @param {string} fullPath 路由路径
  • @param {string} key 组建循环key,唯一,不需要关心
  • @param {string} level 层级
  • @param {string} icon 图标
  1. 获取当前路径
this.$route.meta.paths
  1. 获取当前路路径当前组件的router-view层级
// this 当前组件
this.$vnode.data.routerViewDepth
  1. 获取当前组件的子菜单, 当前组件必须是由router-view渲染
this.$route.meta.paths[this.$vnode.data.routerViewDepth].children
  1. 判断当前组件是否 router-view 渲染
this.$vnode.data.routerView // true 是

examples

  1. ant-design-vue
cd examples/ant-design-vue-demo
npm i
vue serve main.js

更新记录

  1. 1.1 fix meta.key为数字自增

注意

如果没有meta,也必须设置meta字段为{}