Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@npkg/vue-router

npm-pkg56MIT3.5.3TypeScript support: included

This is vue-router3.0 Extended version which works only with Vue 2.0. For the Vue3.0 router see the npm-pkg/vue-router@next. > The extension supports automatic jump to external link

vue-router, link, router-link, vue2.0, extend, External links

readme

@npkg/vue-router release candidate Build Status GitHub license Vue Version Download

This is vue-router3.0 Extended version which works only with Vue 2.0. For the Vue3.0 router see the npm-pkg/vue-router@next. The extension supports automatic jump to external link

View Chinese document

Quickstart

  • Via CDN: <script src="https://unpkg.com/@npkg/vue-router"></script>

  • Add it to an existing Vue Project:

    npm install @npkg/vue-router
    |
    yarn add @npkg/vue-router

Usage

Replace all places of vue-router with @npkg/vue-router

Create routing instance

//# /src/router/index.js

/*
 * Old code
 */
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// Create routing instance
export default new Router({
  mode: 'history',
  routes: [
    ...
  ]
})
//---------------------------------
// replace with the following code
//-----------------------------------


/*
 * New code
 */
import Vue from 'vue'
import Router from '@npkg/vue-router'
Vue.use(Router)

// Create routing instance
export default new Router({
  mode: 'history',
  routes: [
    ...
  ]
})

Based on the original Vue router, it additionally supports the following writing methods


// Basic usage

<router-link to="/"></router-link>

<router-link to="/list"></router-link>

<router-link to="https://github.com/npm-pkg/vue-router"></router-link>

<router-link to="https://github.com/npm-pkg/vue-router?author=five-great"></router-link>

<router-link to="https://github.com/npm-pkg/vue-router/tree/v3.5.3#readme"></router-link>

//Advanced Usage

<router-link :to="{path: '/'}"></router-link>

<router-link :to="{path: '/list'}"></router-link>

<router-link :to="{path:'https://github.com/npm-pkg/vue-router'}"></router-link>

<router-link :to="{path:'https://github.com/npm-pkg/vue-router', query:{author: 'five-great'}}"></router-link>

<router-link :to="{path:'https://github.com/npm-pkg/vue-router/tree/v3.5.3',hash:'#readme'}"></router-link>

<router-link :to="{path:'https://github.com/:org/:repo',params:{org:'npm-pkg',repo: 'vue-router'}}"></router-link>

<router-link :to="{path:'https://github.com/:org/:repo/tree/:v',query:{author: 'five-great'},params:{org:'npm-pkg',repo: 'vue-router',v:'v3.5.3'},hash:'#readme'}"></router-link>

Get started with the documentation.

Contact

github https://github.com/npm-pkg/vue-router/tree/v3.5.3

Email fivecc@qq.com

CSDN Five-菜鸟级

changelog

3.5.2 (2021-06-21)

Bug Fixes

3.5.1 (2021-01-26)

Bug Fixes

3.5.0 (2021-01-25)

Features

  • link: exact-path prop (825328e), closes #2040
  • warn: warn deprecated addRoutes (2e41445)
  • expose START_LOCATION (53b68dd), closes #2718
  • link: deprecate v-slot without custom prop (ceeda4c)
  • link: warn deprecated props (d2cb951)
  • router: add getRoutes (6bc30aa)
  • types: add types for getRoutes addRoute (fb9bb60)
  • addRoute as nested route (ca80c44), closes #1156

3.4.9 (2020-11-05)

Bug Fixes

3.4.8 (2020-10-26)

Features

  • scroll: add behavior support on scrollBehavior (#3351) (4e0b3e0)

3.4.7 (2020-10-16)

Bug Fixes

  • matcher: should try catch decode only (1f32f03)
  • query: check existing keys (4b926e3), closes #3341

3.4.6 (2020-10-07)

Bug Fixes

3.4.5 (2020-09-26)

Bug Fixes

  • history: do not call onReady on initial redirection (a1a290e), closes #3331

3.4.4 (2020-09-24)

Bug Fixes

  • abstract: call afterHooks with go (4da7021), closes #3250
  • history: mark redundant navigation as pending (893d86b), closes #3133
  • types: add missing NavigationFailure types (fda7067), closes #3293
  • types: fix VueRouter.NavigationFailureType (ecc8e27)

Features

  • history: Reset history.current when all apps are destroyed (#3298) (c69ff7b)

3.4.3 (2020-08-11)

  • Revert 4fbaa9f7880276e661227442ef5923131a589210: "fix: keep repeated params in query/hash relative locations" Closes #3289

3.4.2 (2020-08-07)

Bug Fixes

  • query: leave object as is (7b3328d), closes #3282
  • keep repeated params in query/hash relative locations (4fbaa9f)

3.4.1 (2020-08-06)

Bug Fixes

  • query: remove undefined values (b952573), closes #3276
  • router: properly check null and undefined in isSameRoute (d6546d9)

3.4.0 (2020-08-05)

Bug Fixes

Features

  • add vetur tags and attributes (bf1e1bd)
  • errors: capture errors thrown in redirect callback in onError (#3251) (40e4df7), closes #3201 #3201 #3201
  • errors: expose isNavigationFailure (8d92dc0)
  • errors: NavigationDuplicated name for backwards compatibility (b854a20)

3.3.4 (2020-06-13)

Bug Fixes

3.3.3 (2020-06-12)

Bug Fixes

Features

  • better wording for navigation redirected failure (1f3aea6)
  • types: RouterConfig for multiple components (#3217) (#3218) (dab86c5)

3.3.2 (2020-05-29)

Bug Fixes

3.3.1 (2020-05-27)

Bug Fixes

  • errors: avoid unnecessary log of errors (2c77247)

3.3.0 (2020-05-27)

Features

3.2.0 (2020-05-19)

Bug Fixes

  • html5: make base case insensitive (04a2143), closes #2154
  • check for pushState being a function (bc41f67), closes #3154

Features

3.1.6 (2020-02-26)

Bug Fixes

  • preserve history state when reloading (a4ec3e2)
  • ts: add null to Route.name (#3117) (8f831f2)
  • correctly calculate path when pathMatch is empty string (#3111) (38e6ccd), closes #3106

3.1.5 (2020-01-15)

Bug Fixes

  • view: add passing props to inactive component (#2773) (0fb1343), closes #2301
  • view: fix deeply nested keep-alive router-views displaying (#2930) (0c2b1aa), closes #2923

3.1.4 (2020-01-14)

Bug Fixes

Features

  • history: preserve existing history.state (c0d3376), closes #3006

3.1.3 (2019-08-30)

Bug Fixes

  • link: merge event listeners when provided in an anchor (e0d4dc4), closes #2890

Features

3.1.2 (2019-08-08)

Bug Fixes

  • types: prioritize promise based push/replace (1243e8b)

Reverts

3.1.1 (2019-08-06)

Bug Fixes

  • link: silence back navigations errors (59b6da3)

3.1.0 (2019-08-06)

Bug Fixes

  • abstract history: allow router.back in abstract mode when 2 consecutive same routes appear in history stack (#2771) (8910979), closes #2607
  • hash: correctly place query if placed before hash (#2851) (b7715dc), closes #2125 #2262
  • link: Fix active links when parent link redirects to child (#2772) (64785a9), closes #2724
  • adapt error to work on IE9 (527d6d5)

Features

3.0.7 (2019-07-03)

Bug Fixes

  • apps loaded from Windows file shares not mapped to network drives (#2774) (c2c78a3)
  • make callback of next in beforeRouterEnter more consistent (#2738) (8ac478f), closes #2761 #2728

3.0.6 (2019-04-17)

Bug Fixes

3.0.5 (2019-04-15)

Bug Fixes

3.0.4 (2019-04-12)

Bug Fixes

Features

3.0.3 (2019-04-08)

Bug Fixes

3.0.2 (2018-11-23)

Bug Fixes

  • errors: throws with invalid route objects (#1893) (c837666)
  • fix the test in async.spec.js (#1953) (4e9e66b)
  • initial url path for non ascii urls (#2375) (c3b0a33)
  • only setupScroll when support pushState due to possible fallback: false (#1835) (fac60f6), closes #1834
  • workaround replaceState bug in Safari (#2295) (3c7d8ab), closes #2195
  • hash: support unicode in initial route (8369c6b)
  • history-mode: correcting indentation in web.config example (#1948) (4b071f9)
  • match: use pathMatch for the param of * routes (#1995) (ca1fccd), closes #1994

Features

3.0.1 (2017-10-13)

Bug Fixes

3.0.0 (2017-10-11)

Features

BREAKING CHANGES

  • typings: It is no longer compatible with the old Vue typings

2.8.0 (2017-10-11)

Bug Fixes

  • allow insllation on extended Vue copies (f62c5d6)
  • avoid first popstate event with async guard together (fix #1508) (#1661) (3cbc0f3)
  • deep clone query when creating routes (effb114), closes #1690
  • fix scroll when going back to initial route (#1586) (c166822)
  • handle null values when comparing objects (#1568) (4e95bd8), closes #1566
  • resolve native ES modules (8a28426)
  • send props not defined on the route component in $attrs. Fixes #1695. (#1702) (a722b6a)

Features

  • enhance hashHistory to support scrollBehavior (#1662) (1422eb5)
  • scrollBehavior accept returning a promise (#1758) (ce13b55)

2.7.0 (2017-06-29)

Features

  • auto resolve ES module default when resolving async components (d539788)