(四)在 pinia 里面创建状态

老怪兽2022年11月28日
  • pinia 状态管理工具
  • Vue和Pinia
小于 1 分钟

一、在 pinia 里面创建状态

  • defineStore 里面定义状态就跟在组件当中定义是一样的,使用 vueref 函数来定义,然后通过 return 来返回出去
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useNoteStore = defineStore('note', () => {
    const nodeList = ref([
        {
            // ...
        }
    ])

    return {
        nodeList
    }
})
Loading...