JSZip imgData未定义

时间:2019-02-04 13:49:21

标签: javascript jszip

var data=[{"tOffice":123,"cType":5000,"band":-4877,"minCh":12,"maxCh":20},{"tOffice":123,"cType":5000,"band":-4877,"minCh":1,"maxCh":2},{"tOffice":123,"cType":5000,"band":-4877,"minCh":11,"maxCh":12},{"tOffice":123,"cType":6000,"band":-5877,"minCh":11,"maxCh":12},{"tOffice":456,"cType":5000,"band":-4544,"minCh":12,"maxCh":20},{"tOffice":456,"cType":5000,"band":-4544,"minCh":10,"maxCh":11},{"tOffice":456,"cType":6000,"band":-5211,"minCh":12,"maxCh":20},{"tOffice":456,"cType":6000,"band":-5211,"minCh":12,"maxCh":20},{"tOffice":456,"cType":6000,"band":-5211,"minCh":12,"maxCh":20}];

const merged = data.reduce((r,{tOffice, cType, minCh, maxCh})=>{
  const office = r[tOffice] =  r[tOffice] || {tOffice, bandType:{}};
  const band = `${tOffice}-${cType}`
  
  const nested = office.bandType[band] 
               = office.bandType[band] || {band, minMaxCharge:[]};
               
  nested.minMaxCharge.push({minCh, maxCh})
  return r
},{})

const final = Object.values(merged);
final.forEach(a => a.bandType = Object.values(a.bandType))

console.log(final)

运行上面的代码时出现错误:未捕获的ReferenceError:未定义imgData

如何使它起作用?我试图在文档中找到有关它的更多信息,但找不到任何东西。我认为这应该开箱即用吗?

0 个答案:

没有答案