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

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -