H
H
HitGirl2021-06-24 18:23:18
JavaScript
HitGirl, 2021-06-24 18:23:18

Why doesn't dynamic import work?

Hello!
1 and 3 are displayed in the console, 2 is not displayed, please tell me why the import is not performed?

loadData(){
      console.log("1")
      let name = 'file1'
      let data = []
      import('../files/' + name + '.js').then(module => {console.log('2');data=module.default})
      console.log("3")
      return data
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Dubrovin, 2021-06-25
@alekcena

https://learn.javascript.ru/modules-dynamic-imports

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question