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

mpvue-router-patch

v2.0.0

Published

在 mpvue 中使用 vue-router 兼容的路由写法

Downloads

63

Readme

mpvue-router-patch

在 mpvue 中使用 vue-router 兼容的路由写法

npm package npm downloads

安装

npm i mpvue-router-patch

使用

// main.js
import Vue from 'vue'
import MpvueRouterPatch from 'mpvue-router-patch'

Vue.use(MpvueRouterPatch)

API

支持以下列出的方法及属性

Router 实例

属性

  • $router.app

当前页面的 Vue 实例

  • $router.mode

路由使用的模式,固定值 history

  • $router.currentRoute

当前路由对应的路由信息对象,等价于 $route

方法

  • $router.push(location, onComplete?, onAbort?, onSuccess?)

跳转到应用内的某个页面,mpvue.navigateTompvue.switchTabmpvue.reLaunch 均通过该方法实现,location 参数支持字符串及对象两种形式,跳转至 tabBar 页面或重启至某页面时必须以对象形式传入

// 字符串
router.push('/pages/news/detail')

// 对象
router.push({ path: '/pages/news/detail' })

// 带查询参数,变成 /pages/news/detail?id=1
router.push({ path: '/pages/news/detail', query: { id: 1 } })

// 切换至 tabBar 页面
router.push({ path: '/pages/news/list', isTab: true })

// 重启至某页面,无需指定是否为 tabBar 页面,但 tabBar 页面无法携带参数
router.push({ path: '/pages/news/list', reLaunch: true })
  • $router.replace(location, onComplete?, onAbort?, onSuccess?)

关闭当前页面,跳转到应用内的某个页面,相当于 mpvue.redirectTolocation 参数格式与 $router.push 相似,不支持 isTabreLaunch 属性

  • $router.go(n)

关闭当前页面,返回上一页面或多级页面,n 为回退层数,默认值为 1

  • $router.back()

关闭当前页面,返回上一页面

路由信息对象

属性

  • $route.path

字符串,对应当前路由的路径,总是解析为绝对路径,如 /pages/news/list

  • $route.params

空对象,小程序不支持该属性

  • $route.query

一个 key/value 对象,表示 URL 查询参数。例如,对于路径 /pages/news/detail?id=1,则有 $route.query.id == 1,如果没有查询参数,则是个空对象。

  • $route.hash

空字符串,小程序不支持该属性

  • $route.fullPath

完成解析后的 URL,包含查询参数和 hash 的完整路径

  • $route.name

当前路由的名称,由 path 转化而来