Sizzling Code
Sizzling Code

Reputation: 6080

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

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

Upvotes: 11

Views: 8044

Answers (1)

Orkhan Alikhanov
Orkhan Alikhanov

Reputation: 10060

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.

Upvotes: 29

Related Questions