vue-composition-wrapper
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
useStoreinsetup. - Access Route and Router via
useRouteanduseRouterinsetup. - Add navigation guard via
onBeforeRouteLeaveandonBeforeRouteUpdateinsetup. - Access the current Vue component instance context via
getCurrentInstanceinsetup. - Support
Typescript.
Installation
# yarn
$ yarn add vue-composition-wrapper
# npm
$ npm i vue-composition-wrapper
APIs
| Docs | Version | Support Vue version | Support vue-router version |
|---|---|---|---|
| Core API for v1 | v1.5.3 |
v2.6 and lower |
- |
| Core API for v2 | v2.1.4 |
v2.7 |
- |
| Core API for v3 | v3.0.0 |
v2.7 |
^3.6.5 |
Usage
For Vue(^2.7)
- In current version of
vue-compostion-wrapper, the dependency on@vue/compostion-apihas been removed. Directly use the built-in composition API ofvue@2.7. - 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)
-
To use Composition API in
vue(~2.6.x), you need to use @vue/composition-api . -
@vue/composition-apiis included as dependencies ofvue-composition-wrapper@1.x, so it will be installed automatically. If you already have@vue/composition-apiin your project, please uninstall it first. Because if your@vue/composition-apiversion is too low, it may cause problems. -
Install
@vue/composition-apias 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'
// ...
- If your project has not planned to upgrade
vueto 2.7.x, and uses the 1.x version ofvue-composition-wrapper. Remember to lock the version updates ofvueandvue-template-compilerto the patch version of 2.6.
{
"dependencies": {
"vue": "~2.6.14"
},
"devDependencies": {
"vue-template-compiler": "~2.6.14"
}
}
Related Packages
Version History
| Version | Released | License |
|---|---|---|
| 3.4.0 | MIT | |
| 3.2.0 | MIT | |
| 3.1.2 | MIT | |
| 3.1.1 | MIT | |
| 3.1.0 | MIT | |
| 3.0.2 | MIT | |
| 3.0.1 | MIT | |
| 3.0.0 | MIT | |
| 2.2.0 | MIT | |
| 2.1.4 | MIT | |
| 2.1.3 | MIT | |
| 2.1.2 | MIT | |
| 2.1.1 | MIT | |
| 2.1.0 | MIT | |
| 2.0.0 | MIT | |
| 1.5.3 | MIT | |
| 1.5.2 | MIT | |
| 1.5.1 | MIT | |
| 1.5.0 | MIT | |
| 1.4.1 | MIT | |
| 1.4.0 | MIT | |
| 1.3.4 | MIT | |
| 1.3.3 | MIT | |
| 1.3.1 | MIT | |
| 1.3.0 | MIT | |
| 1.2.5 | MIT | |
| 1.2.4 | MIT | |
| 1.2.3 | MIT | |
| 1.2.2 | MIT | |
| 1.2.1 | MIT |
Showing the latest 30 of 42. See every release on npm
Pre-releases (1)
| Version | Released | License |
|---|---|---|
| 2.0.0-alpha.0 | MIT |