I am venturing into the world of vuejs...
I attempted to retrieve data from my JSON file stored locally, but the decision on which specific JSON file's data to fetch is dynamic.
I keep encountering an error stating 'require' is not defined
and I'm unsure how to resolve it.
I came across some solutions suggesting the use of webpack
or browserify
, but I am uncertain why integration with either of these tools is necessary!
<script>
var mylib = require(`../components/${this.$route.params.uuid}.json`)
export default {
name: "BloePage",
data() {
return {
blogcontent: mylib
}
}
}
</script>
Additionally, I tried a different approach to directly access my JSON file without involving any dynamic logic. However, the same error persists...
export default {
name: "BloePage",
data() {
return {
blogcontent: require('../components/UUDD_WWAA_EEFF_EWWW_AAWW.json')
}
}
}
Error -
16:26 error 'require' is not defined no-undef
✖ 1 problem (1 error, 0 warnings)
@ ./router/index.js 28:11-30:28
@ ./main.js
@ multi (webpack)-dev-server/client?http://192.168.43.171:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./main.js