[Vuejs]-Accessing DOM element in VueJS

0👍

The element is probably not in the scope of your HomeView module.
The good thing is: vm.$broadcast() can take more than one argument, so you can pass the element directly to the function with

this.$broadcast('MapsApiLoaded', this.$els.map);

and in HomeView.vue, you can pass it on with

export default {
    events: {
        MapsApiLoaded: initGISMap;
    }
}

(You don’t have to wrap initGISMap in a closure here.)

Leave a comment