Answer the question
In order to leave comments, you need to log in
How to initialize js class in index.html with a separate file?
I'm using webpack to build scripts into one file.
When initializing a class from mainBoundle.js to index.html , the compiler reports that it doesn't see it. If you copy the class to index.html - everything works.
How to initialize js class in index.html with a separate file?
Answer the question
In order to leave comments, you need to log in
As far as I know in index.html you can only access variables available in the global scope. If you need to access a class from mainBoundle.js write it to window. Something like this:
class SomeClass {
// ...
}
window.__SomeClass = SomeClass;
new window.__SomeClass()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question