My goal is to trigger a function in a Vue component when a prop changes using a watcher:
props: [
'mediaUrl'
],
watch: {
mediaUrl: function() {
this.attemptToLoadImage();
}
},
medthods: {
attemptToLoadImage: function() {
console.log('Attempting to load');
}
},
Despite the watcher being activated (confirmed by logging output), I encounter the following error message:
[Vue warn]: Error in callback for watcher "mediaUrl": "TypeError: this.attemptToLoadImage is not a function"
I am puzzled by this error, as my code seems to follow the example provided in the Vue documentation: https://v2.vuejs.org/v2/guide/computed.html#Watchers.
This issue arises on Vue version 2.4.2.
Your assistance would be greatly valued.