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-tiny

v1.1.5

Published

A router for Vue.js

Downloads

19

Readme

#vue-router-tiny

##A router for Vue.js

重写vue的router,使用Director作为底层框架。

去除vue-router原生bug:

  • HTML5模式下,访问两次同样的地址,记录两次访问
  • 配置/example/:id ,/example/1 跳转到/example/2 时不会重新渲染。

支持函数处理式的url跳转

  • 支持url跳转进行函数处理
  • 对url跳转添加了before,on,leave事件

原生vue实例

  • 传递Vue实例参数,可以配合vuex使用。
  • url事件中,this.vue可访问root vue。

##Install ###npm install

npm install vue-router-tiny

###Download

git clone https://github.com/vvpvvp/vue-router

##option

  • history: 是否为html5模式
  • rootUrl: 为所有的url都添加root,全局添加前缀url
  • defaultUrl: 默认的url,当访问的地址没有route配置时,自动跳转。
  • before: 所有的url跳转之前执行,返回false则停止跳转。

##Use

main.html

<!DOCTYPE html>
<html>

<head>
    <title>demo</title>
</head>

<body>
    <div id="body">
        <router-view></router-view>
    </div>
</body>

</html>

js/router.js

import Router from '../plugin/vue-router';
import create from '../../components/create.vue';
import main from '../../components/main.vue';
import welcome from '../../components/welcome.vue';

var routes = {
    '/': {
        component: main,
        subRoutes: {
            '/create1/:id': {
                name: 'create1',
                component: create
            },
            '/create2/:id': {
                name: 'create2',
                before:function(){
                    console.log("welcome before");
                    // return false;//会让页面无法跳转/welcome
                },
                on:function(){
                    console.log("welcome on");
                },
                leave:function(){
                    console.log("welcome leave");
                },
                component: create,
                subRoutes:{
                    "/:title":function(param){
                        console.log(param.title);
                        console.log(param.id);
                    }
                }
            },
            '/welcome': {
                component: function(resolve){
                    require(["../../components/welcome.vue"],resolve);
                }
            },
            "/alert":function(){
                console.log("alert");
            },
            "/alert2":{
                on:function(){
                    $("#mate").addClass("show");
                },
                leave:function(){
                    $("#mate").removeClass("show");
                }
            }
        }
    }
};

let VueParam = {
    el: '#body'
};

Vue.use(Router);
var router = new Router({
    history:true,
    rootUrl:"/root",
    defaultUrl:"/root"
});


router.map(routes);
router.start(VueParam);

export default router;

注意:当配置了rootUrl时,无需将rootUrl添加至v-link中,包括调用go方法也无需添加。

components/menu.vue

<template>
<div class="menu">
	<ul class="menuList">
        <li><a v-link.literal="/welcome">welcome</a></li>
        <li><a v-link="{name:'create1',params:{id:b},query:{query:1}}">create1{{a}}</a></li>
        <li><a v-link="{name:'create1',params:{id:b},query:{query:1}}">create1{{b}}</a></li>
        <li><a v-link="{name:'create2',params:{id:a},query:{query:1}}">create2</a></li>
        <li><a v-link.literal="/alert">alert</a></li>
	</ul>
</div>
</template>

components/create.vue

<template>
<div>
	<button @click="go" class="button">welcome</button>
</div>
</template>
<script type="text/javascript">
import Router from '../js/router';
export default {
    data() {
        return {};
    },
    methods:{
    	go(){
            Router.go("/welcome");
    	}
    }
}
</script>

##Dependences