我们可以在 js 文件中多次使用 'Apex Wire Method to Function' 类型吗?

Can we use 'Apex Wire Method to Function' type more than once in js file?

当我使用两个 apex Wire Method to Function 类型时,只有一个 wire 方法是响应式的。我不确定我是否做对了。请问有人能帮忙吗?

@wire(totalApplication) 
  wireRecord({ error, data }) {

    if(data){
      this.totalSubcontractApp = data;
      this.error = undefined;
      }else if (error){
      this.error = error;
      this.totalSubcontractApp = undefined;
    }
    };

@wire(partialSubcontractRecord)
 wireRecord({ error, data }) {
     this.paginationList = data;
     this.error = undefined;
    }else if(error){
      this.error = error;
      this.paginationList= undefined;
    }
    };

为您的处理函数选择不同的名称。 “魔法”在 @wire 中,而不是在 wireRecord 名称中。

让我们忽略 JavaScript 中结果的自定义处理程序,忘记整个 ({error, data}) 及其后的所有内容。回归基础,将结果保存在变量中。喜欢 https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.apex 中的 @wire(getContactList) contacts;。您不会有 2 种方法将东西写入相同的变量名,并且一次只抱怨 1 个结果“有效”,对吗?

给他们打电话

@wire(totalApplication) wiredTotalApplication({ error, data }) {...
@wire(partialSubcontractRecord) wiredPartialSubcontractRecord({ error, data }) {...