javascript - Dynamically reference an import -


in ecmascript 6, how can instantiate class imported module variable?

ex: import mymodule './modules/modulename'; let myvar = "mymodule"; let foo = new window[myvar]( params ); 

you have create mapping containing imported modules want dynamically instantiate. e.g.

var classes = {   mymodule, }; 

then can do

new classes[myvar](); 

Comments

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -