3.4.0 • Published 3 months ago

vue-composition-wrapper v3.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

vue-composition-wrapper

A Vue Composition API wrapper for vue(2.x) vue-router(3.x) vuex(3.x). Let you use Composition API more conveniently in vue 2.x projects.

Features

  • Access Store via useStore in setup.
  • Access Route and Router via useRoute and useRouter in setup.
  • Add navigation guard via onBeforeRouteLeave and onBeforeRouteUpdate in setup.
  • Access the current Vue component instance context via getCurrentInstance in setup.
  • Support Typescript.

Installation

# yarn
$ yarn add vue-composition-wrapper

# npm
$ npm i vue-composition-wrapper

APIs

DocsVersionSupport Vue versionSupport vue-router version
Core API for v1v1.5.3v2.6 and lower-
Core API for v2v2.1.4v2.7-
Core API for v3v3.0.0v2.7^3.6.5

Usage

For Vue(^2.7)

  1. In current version of vue-compostion-wrapper, the dependency on @vue/compostion-api has been removed. Directly use the built-in composition API of vue@2.7.
  2. Please install vue-compostion-wrapper@latest. The npm tag is now tagged as latest.
# yarn
$ yarn add vue-composition-wrapper@latest

# npm 
$ npm i vue-composition-wrapper@latest

For Vue(~2.6)

  1. To use Composition API in vue(~2.6.x), you need to use @vue/composition-api .

  2. @vue/composition-api is included as dependencies of vue-composition-wrapper@1.x, so it will be installed automatically. If you already have @vue/composition-api in your project, please uninstall it first. Because if your @vue/composition-api version is too low, it may cause problems.

  3. Install @vue/composition-api as a Vue plugin.

// @/plugins/vue-compostion-api.js
import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'

Vue.use(VueCompositionAPI)

Then, import it in your main.js.

// ...

import '@/plugins/vue-composition-api.js'

// ...
  1. If your project has not planned to upgrade vue to 2.7.x, and uses the 1.x version of vue-composition-wrapper. Remember to lock the version updates of vue and vue-template-compiler to the patch version of 2.6.
{
  "dependencies": {
    "vue": "~2.6.14"
  },
  "devDependencies": {
    "vue-template-compiler": "~2.6.14"
  }
}
3.4.0

3 months ago

3.2.0

5 months ago

2.1.2

1 year ago

2.2.0

12 months ago

2.1.1

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.0

1 year ago

3.1.2

12 months ago

3.1.1

12 months ago

3.0.2

12 months ago

3.1.0

12 months ago

3.0.1

12 months ago

3.0.0

12 months ago

2.0.0

1 year ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

2.0.0-alpha.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.0.2

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.2.5

3 years ago

1.0.7

3 years ago

1.2.4

3 years ago

1.0.6

3 years ago

1.2.3

3 years ago

1.0.5

3 years ago

1.2.2

3 years ago

1.0.4

3 years ago

1.2.1

3 years ago

1.0.3

3 years ago

1.0.10

3 years ago

1.0.0

3 years ago