vuex的取值与操作

store.js

state:{setVal:'  '}

mutatios:{  newSet(state,val){ state.setVal = val }   }

 

 

<script>

import {mapstate,mapMutations} from 'vuex'

取值

computed:{

...mapState(['setVal'])

}

值:this.setVal

更改

methods:{

  ...mapMutatios(['newSet'])

}

this.newSet('传值')

</script>

 

posted on 2022-02-09 14:50  万能的李大少  阅读(141)  评论(0编辑  收藏  举报