0

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".

1
  • 1
    You can user spread operators within methods block, or mixins. Commented May 10, 2020 at 18:06

1 Answer 1

3

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
}
Sign up to request clarification or add additional context in comments.

1 Comment

Do you have a simple working example of this - I can't seem to get it to work. TIA...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.