To avoid this becoming messy and the use of "native" jQuery/javascript I would like to call a function in the child component from the parent, the function I want to exeecute is change_map_data() from the child G_Map.vue in an elegant way, vueish way:
Parent.vue
<template>
<div class="col-md-12">
...
<i v-on:click="change_map_data">change markers</i>
...
<g-map v-bind:map_data="init_data.map"></g-map>
...
</div>
export default {
data() {
return {
init_data: {
map: {
map_ele: 'map'
}
}
}
}
}
</script>
</template>
G_Map.vue:
<template>
<div :id="map_data.map_ele" class="gmap"></div>
</template>
<script>
import init_map from '../../../assets/js/map.js';
export default {
props: ['map_data'],
methods: {
change_map_data: function() { // want to execute this from parent
alert();
}
}
}
</script>
change_map_data()on the child and just rely on the parent changing the boundmap_dataprop to change the map data (is this what you mean?). But there are some situations where you just want to make the child do something that has nothing to do with data binding at all. - Decade Moon