Created
June 30, 2020 05:59
-
-
Save liaooliver/be7831623c921a91f4328263a7c2b946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from "vue"; | |
import Vuex from "vuex"; | |
Vue.use(Vuex); | |
export default new Vuex.Store({ | |
actions: { | |
// actions 中有兩個函式 changeColor & changeTextContent | |
// 這兩個函式上都有做一件事情 => context.commit() | |
// context.commit()這個函式的作用是呼叫 Mutations function 執行改變 state 狀態 | |
changeColor(context, payload) { | |
console.log("檢查 context 的內容有哪些東西:", context); | |
context.commit("changeColor", payload); | |
}, | |
changeTextContent(context, payload) { | |
context.commit("changeTextContent", payload); | |
} | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment