I am struggling to import an array into a Vue component:
This is my simplified component:
<script type="text/babel">
const codes = require('./codes.js');
export default {
props: [],
data() {
return {
countryCodes: codes
}
},
}
</script>
codes.js
(function() {
return ['USA', 'UK']; // The original file has more countries; simplified for readability
});
Even though both the component and codes.js files are in the same directory, the countryCodes
property remains empty. What could be the issue?