Encountering an issue with importing a large quantitative variable in Vue 3. Upon running onMounted
, it seems that the import process is not yet complete, resulting in an error indicating that the variable tesvar
is "uninitialized". The code snippet provided below showcases the problem; note that the variable in question is a sizable object that requires some time to load (simply reducing the size of the variable is not a viable solution).
<script lang="ts" setup>
import { onMounted } from "vue"; //This line works fine
import testvar from "../main"; //The correct location for importing the variable
onMounted(() => { //Execution occurs without errors
console.log(testvar);
// Throws error: "Uncaught ReferenceError: Cannot access 'testvar' before initialization"
}
</script>