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 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-router-mp

v0.2.4

Published

mpvue 中使用的 vue-router 兼容路由,兼容大部分 vue-router API,含导航守卫、命名路由等

Downloads

10

Readme

vue-router-mp

npm bundle size npm downloads license

github travis

vue-router-mp 是在 mpvue 中使用的兼容 vue-router 的路由管理器,兼容常用大部分 vue-router 的 API。

支持的特性有:

  • 编程式的导航
  • 命名路由
  • 导航守卫
  • 路由元信息

请阅读 完整文档

安装

NPM

npm install vue-router-mp --save

直接下载

下载源码 并复制到你的工程。

小程序中引入

import Vue from 'vue'
import VueRouter from 'vue-router-mp'

// 或

const Vue = require('vue')
const VueRouter = require('vue-router-mp')

Vue.use(VueRouter)

起步

由于在小程序中,页面路径是由工程源码的目录结构决定,因此相比 vue-router,不需要再指定路径的组件。

// 1. 定义路由
// 此处由于小程序页面路径与源码一一对应,故无需配置组件
const routes = [
  { path: '/pages/foo' },
  {
    name: 'bar', // 命名路由
    path: '/pages/bar',
    isTab: true // 标记当前路由是一个 Tab
  }
]

// 2. 创建 router 实例,然后传 `routes` 配置
// 你还可以传别的配置参数, 不过先这么简单着吧。
const router = new VueRouter({
  routes // (缩写) 相当于 routes: routes
})

// 现在,应用已经启动了!

通过注入路由器,我们可以在任何组件内通过 this.$router 访问路由器,也可以通过 this.$route 访问当前路由:

export default {
  methods: {
    goBack () {
      window.history.length > 1
        ? this.$router.go(-1)
        : this.$router.push('/pages/foo')
    }
  }
}

请阅读 完整文档