1π
β
If you use a module loader like webpack, you need to import the function inside your store.js
const {functionA} = require('./serviceMixin');
Then export functionA
function functionA(){
}
module.exports = {
functionA
}
3π
Let the first file be First.js and second file be Second.js and both of them be in same folder. The below code is of File First.js
export default function FunctionOne(){
console.log("from file one")
}
Second.js
import FunctionOne from './First.js'
FunctionOne()
1π
In your serviceMixin.js
file you should define the function correctly by adding the function
keyword and export it like :
export function functionA(){
console.log("Hello");
}
then in your store file import it in the top and call it in the action :
import {functionA} from './serviceMixin'
...
mutations: {
autoUpdateDb(state, payload) {
functionA();
},
Source:stackexchange.com