const _toggleModule = {? state: {? ? toggleStatus: 0? },? mutations: {? ? _toggle(state, index) {? ? ? state.toggleStatus = index? ? }? },? actions: {? ? layoutToggle({commit}, index) {? ? ? alert(123)? ? ? commit('_toggle', index)? ? }? },? getter: {? ? toggleStatus(state) {? ? ? return state.toggleStatus? ? }? }}export default new Vuex.Store({? modules: {? ? toggleModule: _toggleModule? }})----------------------------------------------------methods: {? ? ? ...mapActions([? ? ? ? '????????'? ? ? ])? ? }
2 回答

生來(lái)自由
TA貢獻(xiàn)8條經(jīng)驗(yàn) 獲得超5個(gè)贊
? ...mapActions([? ?'你要獲取的actions名字'? ?]),你傳入什么,就會(huì)返回一個(gè)包含對(duì)應(yīng)的actions的對(duì)象,通過(guò)...對(duì)象擴(kuò)展運(yùn)算符,將返回值解析就成為methods的屬性,和平常的方法一樣調(diào)用即可
添加回答
舉報(bào)
0/150
提交
取消