首页 > 解决方案 > 错误 TS2349:无法调用其类型缺少调用签名的表达式。类型 '{ ; }' 没有兼容的调用签名

问题描述

我正在使用 Angular JS 打字稿(数据来自后端 springmicroservices。我正在开发名为 downloadExcel() 的新方法

在我的 component.ts

  Data: {
    //rownum: '',
   // requestID: '',
    student_id: string,
    date: Date,
    // 'month_id': ''
  };

在方法 =>

   ExcelDownload() {

    const subHeader1 = worksheet.addRow(this.headerData);
    subHeader1.getCell(4).value = this.Data(student_id. date); // I do want to retrieve student id and date on my cell (just 2 data)

我得到的错误

ERROR in src/app/Summary/Summary.component.ts(902,35): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{ student_id: string; date: Date; }' has no compatible call signatures.

有什么建议么!谢谢

标签: javascriptjavahtmlangularjstypescript

解决方案


代替

subHeader1.getCell(4).value = this.Data(student_id. date); 

subHeader1.getCell(4).value = `${this.Data.student_id} ${this.Data.date}`;

数据不是函数

在您的数据对象中 studnet_id 应该是 student_id


推荐阅读