J
J
jsprog2019-10-31 22:08:35
Vue.js
jsprog, 2019-10-31 22:08:35

How to attach js files to specific components in Vuejs?

Hey! I want to connect js files to certain components. So that they don't quarrel with each other. Please help me solve this problem

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolino, 2019-10-31
@Nikolino

Use JavaScript modules, i.e. import

<script>
import { something } from "./folder/something";
export default {
  data() {
    return {      
    };
  },
};
</script>

And in the something.js file itself, you can export variables, constants, functions like this:
// something.js
export const something = 'Whatever string you want';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question