我在我的州定義了一些日期,如下所示:this.state = { dates: [ { '2020, 4, 1': { morning: {empty: 'no'}, afternoon: {} }, '2020,6, 1': { morning: {empty: 'no'}, afternoon: {} }, '2020,7, 1': { morning: {empty: 'no'}, afternoon: {} } }, ] };如您所見(jiàn),每個(gè)對(duì)象的關(guān)鍵是日期本身。在我的函數(shù)中,我想返回這些日期,但是當(dāng)我將日期設(shè)置為不在對(duì)象內(nèi)部的鍵時(shí),我該如何正確地做到這一點(diǎn)?getBookedDates(current) { let dates = this.state.dates; return !dates.some(day => current.isSame(day.date, 'day')); }
從以日期字符串為鍵的反應(yīng)狀態(tài)返回
慕田峪9158850
2022-07-21 21:40:11