An open API service indexing awesome lists of open source software.

https://github.com/lianghx-319/vue-hooks

⚡️Awesome Vue Hooks
https://github.com/lianghx-319/vue-hooks

composition-api hooks vue-composition-api vue-hooks vuejs vuejs3

Last synced: 20 days ago
JSON representation

⚡️Awesome Vue Hooks

Awesome Lists containing this project

README

        

# vue-hooks [![NPM Version](https://badgen.net/npm/v/@hanxx/vue-hooks)](https://www.npmjs.com/package/@hanxx/vue-hooks) [![Bundle Size](https://badgen.net/bundlephobia/minzip/@hanxx/vue-hooks)](https://bundlephobia.com/result?p=@hanxx/vue-hooks) [![Build Status](https://img.shields.io/travis/lianghx-319/vue-hooks/master.svg)](https://travis-ci.org/lianghx-319/vue-hooks) [![Code Coverage](https://img.shields.io/codecov/c/github/lianghx-319/vue-hooks.svg)](https://codecov.io/gh/lianghx-319/vue-hooks) [![Total alerts](https://img.shields.io/lgtm/alerts/g/lianghx-319/vue-hooks.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/lianghx-319/vue-hooks/alerts/) [![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/lianghx-319/vue-hooks.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/lianghx-319/vue-hooks/context:javascript) [![Netlify Status](https://api.netlify.com/api/v1/badges/24ca2187-6118-491b-b4d1-684a823b3565/deploy-status)](https://app.netlify.com/sites/nervous-noyce-43dffd/deploys)

> ⚡️ Awesome Vue Hooks Fork From [@u3u/vue-hooks](https://github.com/u3u/vue-hooks)

First of all, the original repository has no response for more features request, so I start this repository and add some common useful features. Welcome PRs.

Using [`@vue/composition-api`](https://github.com/vuejs/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.

Another useful vue-hooks repository is [vue-use-web](https://github.com/Tarektouati/vue-use-web), so some duplicated features will not implement here.

## Install

```sh
yarn add @vue/composition-api @hanxx/vue-hooks
```

## Documentation

Docs are available at

## Usage

> Now don't need `Vue.use(hooks)` to install plugin

```js
// main.js
import Vue from 'vue';
import VueCompositionAPI from '@vue/composition-api';

Vue.use(VueCompositionAPI); // Don't forget to use the plugin!
```

> If use `useDate`, remember installing `dayjs`

```sh
yarn add dayjs
```

```js
// You can use dayjs directly here
import { useDate, dayjs } from '@hanxx/vue-hooks/lib/useDate';
```

> If haven't use `useDate`, `dayjs` is not a necessary dependence

```jsx
import { defineComponent } from '@vue/composition-api';
import { useWindowSize } from '@hanxx/vue-hooks';

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

render() {
const { width, height, widthPixel, heightPixel } = this;
return (


dynamic window size: {width}, {height}

);
},
});
```

## 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](https://github.com/kentcdodds/all-contributors#emoji-key)):



u3u

💻 📖 💡 ⚠️

Han

💻

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!

## License

[MIT](./LICENSE)