vuex存取值

本文介绍了Vuex中如何使用commit进行同步操作,如存储和取值,并讲解了dispatch用于处理异步操作,如向后台发送请求。通过dispatch调用action,再由action调用mutation来完成复杂的业务流程。同时,提到了getters用于获取计算后的状态。
摘要由CSDN通过智能技术生成

commit: 同步操作【mutation 】

this.$store.commit('方法名',值)【存储】

  1. this.$store.commit('newBankName', this.textValue)

this.$store.state.方法名【取值】

dispatch: 异步操作【Action】

this.$store.dispatch('方法名',值)【存储】

this.$store.getters.方法名【取值】

<template>
  <div class="hello">
    <h1>{
  { msg }}</h1>
    <button @click="increment">按钮{
  {doneTodos}}</button>    
      <button @click="incrementAsync">按钮new{
  {doneTodos}}</button>   
  </div>
</template>

<script>
import { mapGetters ,mapActions,mapMutations} from 'vuex'
export default {
  name: 'HelloWorld',
  props: 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值