vue3-usestate
v0.0.7
Published
Vue 3 Application Store Composable
Downloads
4
Maintainers
Readme
Vue3 useState
Composable
Clone of Nuxt3's useState
composable
Install
NPM
npm install vue3-usestate
Yarn
yarn add vue3-usestate
Usage
import { useState } from 'vue3-usestate'
setup() {
const counter = useState('counter', 0)
return { counter }
}
Plugin
Inject state to every instance under this.$state
global property
// main.js
import VueUseState from 'vue3-usestate'
createApp(App).use(VueUseState).mount('#app')
Global Property
// App.vue
computed: {
state() { return this.$state }
}
or
<template>
<div>{{ $state.counter }}</div>
</template>