Hogsmill
Hogsmill

Reputation: 1574

Inporting arbitrary Javascript functions into a Vue.js component

I'm building a project in Vue.js, but it has a quite a lot of Javascript processing (it's all local, so I don't need to have anything server side), and I was wondering if there is a way to import a file that is basically just some processing (mathematical, structure processing, etc.) functions in Javascript - no template, etc. - into a Vue component? It's all working fine using methods in the component, but getting a bit large and "monolithic".

Upvotes: 0

Views: 93

Answers (1)

You can keep working with several files and then just to the following.

import AlgebraicFunctions from 'algebraic-file';
import GeometricFunctions from 'geometric-file';

Using the spread operator:

methods: { 
 ...AlgebraicFunctions,
 ...GeometricFunctions
}

Upvotes: 3

Related Questions