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

vue-composition-wrapper

v3.4.0

Published

composition api wrapper for vue 2.x vue-router 3.x vuex 3.x

Downloads

621

Readme

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

| 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)

  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 [email protected].
  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 [email protected], 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"
  }
}