I recently implemented a plugin that introduces a new property to the Vue instance. This property can then be accessed within components using this.$plugin.prop
. However, I am encountering difficulty in watching for changes to this property. I need to perform actions within the component based on the value of this.$plugin.prop
, but neither the watch
nor this.$watch
methods seem to work for me. It appears that these methods operate within the component context, making it challenging to watch for variables outside of the component.
mounted() {
this.$watch('$plugin.prop', val => console.log(val));
}
How can I effectively handle this situation and keep track of changes to this.$plugin.prop
?