vue.js - VueJS |方法 "watch"在组件定义中具有类型 "object"

标签 vue.js vuejs2 vue-storefront

目前我有以下 watch 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);
        }
      }
    }
  }
但我在控制台中收到以下错误(Vue Warn)

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


enter image description here
我不确定为什么我会收到这个错误,因为我使用的语法似乎是正确的,它甚至可以正常运行。
任何建议为什么它在错误控制台中发出此警告?

更新:
我在 vue 页面中使用 watch 的位置。
enter image description here

最佳答案

你有类似 methods: { watch: {} } 的东西在您的组件定义中。这就是 vue 提示的原因。这可能是由 mixin 添加的以及。

关于vue.js - VueJS |方法 "watch"在组件定义中具有类型 "object",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65301874/

相关文章:

javascript - 无法访问 .beforeEach() 中的 Buefy 组件

javascript - 为基于Vue店面的网上商店设置RSS Feed(Google购物)

magento - Vue 店面安装错误。无法构建店面 npm

javascript - Service Worker已注册成功,但serviceworker.js文件中的代码尚未执行

vue.js - Vue CLI 从项目模块动态导入

javascript - 在组件中声明动态数据,Vuejs 2

typescript - 使用 Vue 3 Composition API 创建全局商店

javascript - 加载数据(最初为空)和没有项目之间的区别

eloquent - Vue 2 Laravel 5.3 Eloquent 无法从对象检索数据

javascript - 如何扩展Vue Storefront核心模块