Skip to content

Dynamic import fails in folder #10906

Answered by chenxch
lonelil asked this question in Q&A
Nov 13, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

My approach is to use the import.meta.glob() method to get the modules first, and then go to the modules to get the corresponding import to execute according to the actual needs.

e.g.

const modules = import.meta.glob('./assets/locales/**/*.json')

modules[`./${language}/${namespace}.json`]()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@m-shum
Comment options

Answer selected by lonelil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants