<template>
<div>
<p>Count: {{ counter.$state.count }}</p>
- <button @click="counter.increment()">
- +
- </button>
+ <button @click="counter.increment()">+</button>
</div>
</template>
export const useCounter = definePiniaStore('counter', {
state: () => ({
- count: 100
+ count: 100,
}),
actions: {
- increment () {
+ increment() {
this.count++
- }
+ },
},
getters: {
- getCount: state => state.count
- }
+ getCount: (state) => state.count,
+ },
})
import piniaModule from '../src/module'
export default defineNuxtConfig({
- modules: [
- piniaModule
- ]
+ modules: [piniaModule],
})