How does Vue listen for changes in global variables within a component

I have defined a global variable Vue.prototype.url in main.js. The value of this variable is returned in the background. How can I monitor the change of this value in the vue component? Cannot listen using watch

watch: {
  "url"(newVal,oldVal) {
    console.log(newVal,oldVal)
  }
}
Feb.26,2021

you can define it in the data of the root component, and vue will automatically listen


are you sure your way of writing is all right?

watch: {
  'url': function(newVal,oldVal) {
    console.log(newVal,oldVal)
  }
}

have you solved your problem? I have encountered the same situation


ide/state-management.html" rel=" nofollow noreferrer "> https://cn.vuejs.org/v2/guide.

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2bd51-2babb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2bd51-2babb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?