VueJS | 方法“watch”在组件定义中具有“object”类型

Siz*_*ode 4 vue.js vuejs2 vue-storefront

目前我在Product.vue文件中有以下手表

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);
        }
      }
    }
  }
Run Code Online (Sandbox Code Playgroud)

但我在控制台中收到以下错误(Vue Warn)

[Vue 警告]:方法“watch”在组件定义中具有“object”类型。您是否正确引用了该函数?

在此处输入图片说明

我不确定为什么我会收到这个错误,因为我使用的语法似乎是正确的,它甚至可以正常运行。

任何建议为什么它在错误控制台中发出此警告?


更新:

我在 vue 页面中使用手表的位置。

在此处输入图片说明

Ork*_*nov 9

methods: { watch: {} }的组件定义中有类似的内容。这就是 vue 抱怨的原因。这也可能由 a 添加mixin