M
M
myskypesla2018-05-08 15:51:24
Vue.js
myskypesla, 2018-05-08 15:51:24

How to properly import a JS file from the static folder?

When importing, the script gives an error that this module is not a constructor.
I'm trying to import a twitch embed api file.
If you insert the script tag into index.html, then everything is ok.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2018-05-08
@bingo347

const script = document.createElement('script');
script.async = true;
script.src = '/static/your-script.js';
document.head.appendChild(script);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question