Hi all! I am trying to do a dynamic import so that my classes are pulled by information from json. In json, I only have popup classes specified that I need to get inside the game. I make an import and put the values into an array, so that I can later put them in the game config. But as a result, I only get the value of the first import, the rest is undefined. Tell me how to correctly perform dynamic imports inside a loop, or is there a fundamentally different approach altogether?
вот мой код с импортом:
var popupsConfig = myConfig.popups
console.log(popupsConfig)
var popups = []
async function getPopups(popupsConfig) {
for (let i = 0; i < popupsConfig.length; i++) {
let obj = await
import (`../src/assets/popups/${myConfig.popups[i].popupType}`)
popups[i] = obj.default
//popups.push(obj.default)
}
}
getPopups(popupsConfig)