As a newcomer to vue.js, I am in the process of consolidating several functions into one js file. Here is an example:
example.js:
function containObject(obj, list) {
for (let i = 0; i < list.length; i += 1) {
if (list[i] === obj) {
return true;
}
}
return false;
}
function pad(n, width, z) {
let x = '';
let p = '';
x = z || '0';
p = n.toString();
return p.length >= width ? p : new Array(width - p.length + 1).join(x) + p;
}
export { containObject, pad };
In order to import them into a vue file, you can do it like this:
example.vue:
import { containObject, pad } from './example';
An issue arises when trying to have two export defaults in one js file. How can these functions be compiled into one file so that they can be used globally without having to redefine them in every file?