VueJS | Method "watch" has type "object" in the component definition

7.5k views Asked by At

Currently I have following Watches in Product.vue file

watch: {
    isOnline: {
      async handler (isOnline) {
        if (isOnline) {
          const maxQuantity = await this.getQuantity();
          this.maxQuantity = maxQuantity;
        }
      }
    },
    isMicrocartOpen: {
      async handler (isOpen) {
        if (isOpen) {
          const maxQuantity = await this.getQuantity();
          this.maxQuantity = maxQuantity;
        }
      },
      immediate: true
    },
    isSample (curr, old) {
      if (curr !== old) {
        if (!curr) {
          console.log('send the updateCall', curr);
          // this.updateProductQty(this.product.qty);
          pullCartSync(this);
        }
      }
    }
  }

but I am getting this following error (Vue Warn) in console

[Vue warn]: Method "watch" has type "object" in the component definition. Did you reference the function correctly?

enter image description here

I'm not sure why i am getting this error, as the syntax i am using seems to be correct, and its even functioning right.

Any suggestions why its giving this warning in error console?


Update:

Location where i have used the watch in vue page.

enter image description here

1

There are 1 answers

0
Orkhan Alikhanov On BEST ANSWER

You have something like methods: { watch: {} } in your component definition. That's why vue is complaining. That might be added by a mixin as well.