I have a Vue component with an empty template that needs to listen to prop changes:
// component.vue
<template>
</template>
<script>
export default {
props: ['mode'],
updated: function() {
console.log('updated!')
}
}
</script>
//parent.vue
<template>
...
<childcomponent :mode="variable"></childcomponent>
</template>
...
Now whenever the parent's variable
changes, I would expect childcomponent.updated
to be called. However, this only seems to happen if the prop is used in the child's template.
The only workaround I came up with so far is to set the child component's template to <div v-show="false>{{ mode }}</div>
, but that really doesn't seem right? Is there a nicer way to solve my issue?
The reason I'm using an empty template in the first place is because the component interacts with js library that does a bunch of DOM manipulations itself.