第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在ext js中的for循環(huán)內(nèi)獲取數(shù)組中的總值總和

如何在ext js中的for循環(huán)內(nèi)獲取數(shù)組中的總值總和

九州編程 2021-12-02 15:56:09
在 for 循環(huán)中,我正在獲取這些數(shù)據(jù)這個值來自 EXT js 商店。  var sum = results.rows.item(i).Count;     console.log(sum);結(jié)果,它顯示2563我需要在一個變量中計算這個總和。任何人都可以回答這個問題,請。這是一個 javascript 函數(shù)。
查看完整描述

2 回答

?
繁華開滿天機

TA貢獻1816條經(jīng)驗 獲得超4個贊

您可以使用該reduce功能:


let array = [2,5,6,3];



// will reduce an array to a single variable.

let sum = array.reduce((collector, num) => {

  // the collector is kept for each iteration

  return collector += num;

}, 0 /* initial value is 0 */);


console.log(sum)


查看完整回答
反對 回復(fù) 2021-12-02
?
慕容森

TA貢獻1853條經(jīng)驗 獲得超18個贊

只需在 store 對象上使用 ExtJS 的內(nèi)置函數(shù):

myStore.sum('items'); // assuming 'items' is the field you need to sum

https://docs.sencha.com/extjs/7.0.0/classic/Ext.data.Store.html#method-sum

如果是分組商店,您還可以獲得分組總和。


查看完整回答
反對 回復(fù) 2021-12-02
  • 2 回答
  • 0 關(guān)注
  • 308 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號