, 提供两个方法
addSubscription
// 向当前state事件队列中注册事件回调
export function addSubscription(..., 主要包括三个核心
defineStore 定义状态
createOptionsStore 对象型状态生成函数 defineStore(id, {state, getter, action})
createSetupStore...$patch 是state更新函数,
this....return computedGetters}
{}
)
}
所以setup主要作用是 1.将getter包裹computed, 2.返回新的store定义,通过getter的包装过程,知道了为什么箭头函数不能使用...$onAction: addSubscription.bind(null, actionSubscriptions),
// state 更新函数
$patch,
// 重置store
$reset