This Vue hook was created as an sample to explain the process to create publishable Open Source Vue libraries.
Tutorial on Medium!
Usage Demo Stackblitz
npm install vue-use-counter
<template>
<div id="app">
<div>
{{ counter }}
</div>
<div>
<button @click="handleClick">Inc</button>
</div>
</div>
</template>
<script>
import { useCounter } from 'vue-use-counter';
export default {
name: 'App',
setup() {
const { counter, inc } = useCounter();
function handleClick() {
inc();
}
return {
counter,
handleClick,
};
},
};
</script>