JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
<div id="app">
<button @click="$counter.increment()" type="button">
{{ $counter.value }}
</button>
</div>
JavaScript
const app = new Vue({
mounted() {
console.log({ counter: this.$counter });
},
});
Vue.use({
install(Vue) {
Vue.prototype.$counter = new Vue({
data: () => ({ value: 1 }),
methods: {
increment() { this.value++ },
}
});
}
})
app.$mount('#app');