Answer the question
In order to leave comments, you need to log in
How to connect an external js script to a single-file vue.js component?
I'm making a vue js project with routing and single-file components. I tried to connect an external script to the component and the module is no longer found, how can I fix this?
Answer the question
In order to leave comments, you need to log in
<script src="./script.js"></script>
It is not vue that connects it, but a plugin of your build system. Most likely vue-loader in webpack
In a single-file component, you can include it like this:
<script>
require('./script.js');
export default {
name: 'component-name',
};
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question