ImはfilteredAlarmsと呼ばれる「アラーム」で私のオブジェクトを除外することができ、計算機能、 フィルタリング、
だから私は作成した
計算された機能を、作成しようとしている、と私のループイムでやってネストされた配列V-用ループ:<li class="event-log__item timeline__item" v-for="(item, key) in filteredAlarms" :key="key">
そして、私のフィルタイムで次の操作を実行しようとしている。
let filteredAlarms = Object.keys(this.eventLog).forEach(key => {
this.eventLog[key].filter(item => {
return item.type.indexOf("alarm") > -1
});
});
return filteredAlarms
残念ながら、これは動作しません - Imがエラーになっ:TypeError例外:this.eventLogを。フィルタは関数ではありません
私は間違っていますか? :)
フィルタリングしようとしているオブジェクトのイムは以下のようなものです:
"system_events": {
"1013": [{
"id": 25899,
"timestamp": "2017-08-15T21:26:42Z",
"type": "alarm",
"code": 190,
"title": "",
"description": "",
"appeared": "2017-08-15T21:26:40Z",
"disappeared": null,
"acknowlegded": null,
"solved": null,
"system_name": "Randers pr 44b sidste station"
},
{
"id": 26157,
"timestamp": "2017-08-15T21:32:17Z",
"type": "warning",
"code": 190,
"title": "",
"description": "",
"appeared": "2017-08-15T21:32:06Z",
"disappeared": null,
"acknowlegded": null,
"solved": null,
"system_name": "Randers pr 44b sidste station"
},
{
"id": 26387,
"timestamp": "2017-08-15T21:37:38Z",
"type": "info",
"code": 190,
"title": "",
"description": "",
"appeared": "2017-08-15T21:37:33Z",
"disappeared": null,
"acknowlegded": null,
"solved": null,
"system_name": "Randers pr 44b sidste station"
}],
"1015": [{
"id": 23777,
"timestamp": "2017-08-15T20:38:08Z",
"type": "alarm",
"code": 191,
"title": "",
"description": "",
"appeared": "2017-08-15T20:38:00Z",
"disappeared": null,
"acknowlegded": null,
"solved": null,
"system_name": "Favrskov Svenstrup gyvelvej"
},
{
"id": 23779,
"timestamp": "2017-08-15T20:38:08Z",
"type": "alarm",
"code": 190,
"title": "",
"description": "",
"appeared": "2017-08-15T20:37:58Z",
"disappeared": null,
"acknowlegded": null,
"solved": null,
"system_name": "Favrskov Svenstrup gyvelvej"
},
{
"id": 23841,
"timestamp": "2017-08-15T20:39:41Z",
"type": "alarm",
"code": 192,
"title": "",
"description": "",
"appeared": "2017-08-15T20:39:31Z",
"disappeared": null,
"acknowlegded": null,
"solved": null,
"system_name": "Favrskov Svenstrup gyvelvej"
},
{
"id": 25243,
"timestamp": "2017-08-15T21:12:03Z",
"type": "alarm",
"code": 191,
"title": "",
"description": "",
"appeared": "2017-08-15T21:11:55Z",
"disappeared": null,
"acknowlegded": null,
"solved": null,
"system_name": "Favrskov Svenstrup gyvelvej"
},
{
"id": 25529,
"timestamp": "2017-08-15T21:18:11Z",
"type": "alarm",
"code": 190,
"title": "",
"description": "",
"appeared": "2017-08-15T21:18:00Z",
"disappeared": null,
"acknowlegded": null,
"solved": null,
"system_name": "Favrskov Svenstrup gyvelvej"
}]
}
'map'は配列を生成しますが、' filteredAlarms'はオブジェクトを保持する必要があります。 – dfsq
@dfsqはい、私はそれを今実現しました、私はコードを編集しました。 – kudlajz