I have a component vue ( Map.vue
):
<template>
...
</template>
<script>
import '../../assets/js/map.js'
export default {
name: 'home',
data () {
return {
init_data: {},
}
},
created: function() {
this.init_data = window.get_init_data(this.view, function(response) {
document.title = response.body.page_title;
init_map(some_arguments); // erro aqui
});
}
}
</script>
map.js:
const key = ******;
function init_map(some_args) {
...
}
Error:
[Vue Warn]: Error in created hook: "ReferenceError: init_map is not defined "
And in fact, by inspecting the source code the function is being called before its signature.
Note: I do not want to include map.js
in my webpack entries because I will only need this script in a component.