I have some extra code from another guy. and i don't know how can i use it
i tried use this function,like any other component from store in index.js in index.js i registred modules:
export const store = new Vuex.Store({
state: {},
getters: {},
mutations: {},
actions: {
},
modules: {
person,
applications,
},
strict: false
});
let fillTotal = function (s) {
return{...}};
export default function (fatJSON) {
let obj = fillTotal(fatJSON);
obj = Object.assign(demoObj, obj);
axios.post(
'http://someaddress',
obj
).then(r => console.log(r));
// console.log('obj', obj);
// console.log('fatStore', fatStore);
}
My component:
template>
<div>
<div class="clear_save_button row">
<button @click="onSave">Сохранить</button>
</div>
</div>
</template>
<script>
import myFunction from '/src/store/index.js'
methods: {
executeMyFunction(FatJson){
myFunction(FatJson);
},
onSave() {
this.executeMyFunction(this.person);
AXIOS.post(`/profile`, (this.person))
.then(response => {...
I have post method in component like: AXIOS.post(/profile
, (this.person))
how send this.person used this function from store?
just import that function and call it inside a method like this :
UPDATED :
// src/store/index.js
let fillTotal = function(s) {...}
export const myFunction = (fatJSON) => {
let obj = fillTotal(fatJSON);
obj = Object.assign(demoObj, obj);
axios.post(
'http://1ss.loc',
obj
).then(r => console.log(r));
}
// in component.vue
import {myFunction} from '@/src/store/index.js';
export default {
methods: {
executeMyFunction() {
myFunction();
}
}
}