⚡️ Awesome Vue Hooks Fork From @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 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, so some duplicated features will not implement here.
yarn add @vue/composition-api @hanxx/vue-hooksDocs are available at https://vue-hooks.hanxx.icu
Now don't need
Vue.use(hooks)to install plugin
// 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 installingdayjs
yarn add dayjs// You can use dayjs directly here
import { useDate, dayjs } from '@hanxx/vue-hooks/lib/useDate';If haven't use
useDate,dayjsis not a necessary dependence
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 (
<div id="app" style={{ width: widthPixel, height: heightPixel }}>
dynamic window size: {width}, {height}
</div>
);
},
});- Fork it!
- Create your feature branch:
git checkout -b feat/new-hook - Commit your changes:
git commit -am 'feat(hooks): add a new hook' - Push to the branch:
git push origin feat/new-hook - Submit a pull request :D
Thanks goes to these wonderful people (emoji key):
u3u 💻 📖 💡 |
Han 💻 |
This project follows the all-contributors specification. Contributions of any kind are welcome!