Vue3.x集成 Pinia之State

3/29/2022

这里说一下Store中state的两种声明方法

以上一章的 useMainStore 为例

import { defineStore } from 'pinia'
export const useMainStore = defineStore('main', {
    state: () => {
        return {
            name:'JunQiu',
            age:20,
            count:10
        }
    }
})

import { defineStore } from 'pinia'
export const useMainStore = defineStore('main', {
    state:()=>({
        name:'JunQiu',
        age:20,
        count:10
    })
})  

Last Updated: 3/15/2024, 2:13:06 PM