跳至内容

API 文档文档


API 文档 / pinia / MutationType

枚举:MutationType

SubscriptionCallback 的可能类型

枚举成员

direct

direct: "direct"

直接修改状态

  • store.name = 'new name'
  • store.$state.name = 'new name'
  • store.list.push('new item')

patchFunction

patchFunction: "patch function"

使用 $patch 和函数修改状态

  • store.$patch(state => state.name = 'newName')

patchObject

patchObject: "patch object"

使用 $patch 和对象修改状态

  • store.$patch({ name: 'newName' })