first commit
This commit is contained in:
40
loginmulti/store/moduleA.js
Normal file
40
loginmulti/store/moduleA.js
Normal file
@@ -0,0 +1,40 @@
|
||||
// src/store/moduleA.js
|
||||
const moduleA = {
|
||||
namespaced: true,
|
||||
state() {
|
||||
return {
|
||||
count: 0,
|
||||
data: null
|
||||
};
|
||||
},
|
||||
mutations: {
|
||||
increment(state) {
|
||||
state.count++;
|
||||
},
|
||||
decrement(state) {
|
||||
state.count--;
|
||||
},
|
||||
setData(state, payload) {
|
||||
state.data = payload;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async login({ state, commit }) {
|
||||
const params = {
|
||||
email: state.email,
|
||||
password: state.password
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.post(URL + '/login', params);
|
||||
commit('setData', response.data);
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Export moduleA as a global variable
|
||||
window.moduleA = moduleA;
|
||||
|
||||
Reference in New Issue
Block a user