1. 程式人生 > >vue對映函式mapState mapActions mapMutations mapGetters

vue對映函式mapState mapActions mapMutations mapGetters

通過擴充套件運算子,將store裡的state/actions/mutations/getters的屬性或者方法直接對映到當前vue物件的this上,使用時直接this。xxx
使用前需要先引入

import {mapState, mapActions, mapMutations, mapGetters} from 'vuex'
...mapState(['address', 'categorys'])
this.address