問題一:
_ob_: Observer是受vue監(jiān)控的數(shù)據(jù),無法直接枚舉里面的數(shù)據(jù)
解決:
官方方法 JSON.parse(JSON.stringify(Array))
問題二:
如果是異步請求,確保得到了數(shù)據(jù)。
解決:
把相關(guān)數(shù)據(jù)操作寫在.then()里
getWristbandStatisticDatas(params).then(res => {
this.originData = [];
this.loading = false
res &&
_.forEach(res, (item) => {
this.originData.push({
time: _.get(item, 'xAxisTitle',''),
激活設(shè)備數(shù): _.get(item, 'activatedDeviceCount',0),
在線用戶數(shù): _.get(item, 'onlineDeviceCount',0),
生理指標(biāo)數(shù): _.get(item, 'indicatorCount',0),
消息數(shù): _.get(item, 'receivedMessageCount',0),
});
// 數(shù)據(jù)處理
let ds = new DataSet();
let dv = ds.createView().source(this.originData);
dv.transform({
type: 'fold',
fields: ['激活設(shè)備數(shù)','在線用戶數(shù)','生理指標(biāo)數(shù)','消息數(shù)'], // 展開字段集
key: 'type', // key字段
value: 'count' // value字段
});
this.chartdata = dv.rows;
});
});