Created
November 21, 2021 18:29
-
-
Save Pigamo/9d2c6633f4044e4fc4b4c8adb7f48e05 to your computer and use it in GitHub Desktop.
Based on StackOverflow Question, how to import multiple json files dynamically without specifically calling each one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = import.meta.glob('../data/*.json') | |
const imp = ref([{}]) | |
// eslint-disable-next-line no-restricted-syntax | |
for (const path in data) { | |
data[path]().then((mod) => { | |
// const p = new URL(path, import.meta.url) | |
// eslint-disable-next-line no-console | |
console.log(path) | |
// imp.value.push(path) | |
imp.value.push(mod) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment