[Vuejs]-Vue JS Component calling functions in JS Files

0👍

not sure what you’re trying to do but maybe this will help:

MainComponent.vue

import { _data } from './DataComponent'
    data() {
       return _data
    }

DataComponent.js

export const _data = {
var1:[],
var2: []
}

0👍

you must export js module then import inside Component for example

Test.js

module.exports = {
     getData() {
        variable1: [],
        variable2: []
     }
};

MyComponent.vue

import { obj } from 'your_js_file_path/Test'

then you can use forexamle inside some method

obj.getData();

Leave a comment