OKdevTV Docs
Home OKdevTV
ESC
vue 1 min read 0.4 KB Raw Markdown
On this page (2)

Pinia

Install

text
npm install pinia --save

example

js
// stores/counter.js
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', {
  state: () => {
    return { count: 0 }
  },
  // could also be defined as
  // state: () => ({ count: 0 })
  actions: {
    increment() {
      this.count++
    },
  },
})