在 pdfmake 上关联另一个数组的列

associate a column of another array on pdfmake

在我的项目中,我想关联一个数组的值,而不是前两列中存在的值。这是可能的? (partialPrice 值的数量与 code 存在的数量相同)。我已经试过了,但它不起作用:

interv: Intervention[]
partialPrice = []
{
          table: {
            headerRows: 1,
            widths: ['auto', 'auto', 'auto'],
            body: [
              ['Code', 'Description', 'Price'],
              ...this.interv.map(intervObj => 
                  [intervObj.intervention.code, intervObj.intervention.description],
                  this.partialPrice.map(price =>
                    [price])
              )
            ]
          }
        },

因此,您需要根据您在 interv 数组上使用的 map() 的当前索引从 partialPrice 数组中提取元素。所以,这应该有效:

  body: [
          ['Code', 'Description', 'Price'],
          ...this.interv.map((intervObj, index) => 
              [intervObj.intervention.code, intervObj.intervention.description, partialPrice[index]]
          )
        ]