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

st-vue-router-plus

v0.3.9

Published

this vue-router-plus is extends from vue-router but plus some features

Downloads

11

Readme

vue-router-plus

this vue-router-plus is extends from vue-router but plus some features

notice

vue-router-plus now only compatibable with [email protected] because the vue-router 3.1.* upper use the promise style that will product uncaught promise error,see this

  • all navigation behavior will be force style
  • routes config support queryOptions,and add $route.meta.query
  • vm.$searchQuery
  • wrapper function plusHook, just wrap the original route hook
  • router.isHistoryBF,whether the router is in popstate progressing
  • infinite redirect loop will throw Error

use

import Vue from 'vue'
import VueRouterPlus from 'vue-router-plus'


Vue.use(VueRouterPlus,{
  // same as vue-router options,
  // maxRedirect:{  infinite redirect loop upper limit
  //    count: 20,
  //   duration: 3000
  // }
})

force push && replace

all route-link .push .replace will be force mode,to resolve same route redirect loop problem

// force push some path,even the final path is same, it will append _f query
//  /a?age=1&_f=1
this.$router.push({
  path: '/a',
  query: {
    age: 1
  }
})
this.$router.replace({
  path: '/a',
  query: {
    age: 1
  }
})

router.reload()

reload spa will reload with the currentRoute

this.$router.reload()

router.isHistoryBF {boolean}

a tag show whether the user press the browser forward or backward button

  • only effect in history mode

queryOptions

typed query options in routes config meta

routes.js

;[
  {
    path: '/a',
    meta: {
      queryOptions: {
        age: { type: Number, default: 20 },
        name: { type: String, default: 'lee' }
      }
    }
  }
]

then route.meta.query will be

  • /a -> {age: 20, name: 'lee' }
  • /a?age=33 -> {age: 33,name:'lee' }
  • /a?age=22&name=cc -> {age:22,name:'cc'}

plusHook Support

the plusHook function can do a lot things that reduce the time on debug vue-router

  • resolve the same route loop problem,by always append _f query on next function
  • support promisable or subscribe style route hook
  • auto enabled in global hook like router.beforeEach and router.beforeResolve
router.beforeEach(to => {
  console.log(to) // sync hook
})
router.beforeEach(to => {
  return Promise.resolve({ // hook will resolved when promise is resolved
    a: 1
  })
})

import {of} from 'rxjs;
router.beforeEach(to=>{
  return of(3) // hook will auto subscribe the stream
})

redirect sense

router.beforeEach((to, from, next) => {
  if (to.path === '/parent') {
    next('/parent/child') // -> /prent/child?_f=3
    return // this return prevent the below `next` function excute
  }
  next()
})

use plusHook in mixin or .vue

a.vue

<script>
  import { plusHook } from 'vue-router-plus'

  export default {
    beforeRouteEnter: plusHook(function(to) {
      console.log(to)
    }),
    beforeRouteUpdate: plusHook(function(to) {
      console.log(this)
      console.log(to)
    })
  }
</script>

$searchQuery

now vue instance provide a prop name $searchQuery is equal to to.meta.query

  • $searchQuery === $route.meta.query

extra router prop

same to beforeEach to,from,next

  • router.to
  • router.from
  • router.next