Skip to content
该翻译已同步到了 的版本,其对应的 commit hash 是 c67a5c9

API 文档 / pinia / MutationType

Enumeration: MutationType

pinia.MutationType

SubscriptionCallback 的可能类型

Enumeration Members

direct

direct = "direct"

Direct mutation of the state:

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

patchFunction

patchFunction = "patch function"

通过 $patch 和一个函数更改 state:

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

patchObject

patchObject = "patch object"

通过 $patch 和一个对象更改 state:

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

Released under the MIT License.