目前我有以下 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?
我不确定为什么我会收到这个错误,因为我使用的语法似乎是正确的,它甚至可以正常运行。
任何建议为什么它在错误控制台中发出此警告?
更新:
我在 vue 页面中使用 watch 的位置。
最佳答案
你有类似 methods: { watch: {} }
的东西在您的组件定义中。这就是 vue 提示的原因。这可能是由 mixin
添加的以及。
关于vue.js - VueJS |方法 "watch"在组件定义中具有类型 "object",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65301874/