P
P
Pavel Mikhalovsky2018-02-20 14:02:40
JavaScript
Pavel Mikhalovsky, 2018-02-20 14:02:40

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

2 answer(s)
A
Anton Shvets, 2018-02-20
@Xuxicheta

<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

D
Denis Korablev, 2018-02-21
@Reallyrails

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 question

Ask a Question

731 491 924 answers to any question