@u3u/vue-hooks
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

vue-hooks NPM Version Build Status Code Coverage

⚡️ Awesome Vue Hooks

Using @vue/composition-api to implement useful vue hooks.
Vue 3.0 has not been released yet, it allows you to use functional-based components in advance.

⚠️ 2.x has been switched to @vue/composition-api, if you are using version 1.x please use vue-function-api

Install

yarn add @vue/composition-api @u3u/vue-hooks

Documentation Netlify Status

Docs are available at https://vue-hooks.netlify.com

Usage

Edit Vue Hooks Examples

import Vue from 'vue';
import VueCompositionAPI from '@vue/composition-api';
import hooks from '@u3u/vue-hooks';

Vue.use(hooks);
Vue.use(VueCompositionAPI); // Don't forget to use the plugin!
import { createComponent } from '@vue/composition-api';
import { useWindowSize } from '@u3u/vue-hooks';

export default createComponent({
  setup() {
    const { width, height, widthPixel, heightPixel } = useWindowSize();
    return { width, height, widthPixel, heightPixel };
  },

  render() {
    const { width, height, widthPixel, heightPixel } = this;
    return (
      <div id="app" style={{ width: widthPixel, height: heightPixel }}>
        dynamic window size: {width}, {height}
      </div>
    );
  },
});

Hooks

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b feat/new-hook
  3. Commit your changes: git commit -am 'feat(hooks): add a new hook'
  4. Push to the branch: git push origin feat/new-hook
  5. Submit a pull request :D

Contributors

Thanks goes to these wonderful people (emoji key):

u3u
u3u

💻 📖 💡 ⚠️

This project follows the all-contributors specification. Contributions of any kind are welcome!

License

MIT

Package Sidebar

Install

npm i @u3u/vue-hooks

Weekly Downloads

197

Version

2.0.1

License

MIT

Unpacked Size

58 kB

Total Files

84

Last publish

Collaborators

  • u3u