将值从多维数组传递给对象

时间:2018-11-03 14:05:48

标签: javascript fullcalendar

我正在创建一个日历以查看日历中的班次,我将从后端获取数据作为值数组 数组将是

 var shift = [morning shift,10:00,15:00,10/10/2018,15/10/2018],[[noon shift,10:00,15:00,10/09/2018,15/09/2018]]

表示[班次名称,班次开始时间,班次结束时间,班次开始日期,班次结束日期]

我必须将此值作为

传递给对象
     var repeatingEvents = [{
        title:"morning shift",
        start: '10:00', // a start time (10am in this example)
        end: '15:00', // an end time (6pm in this example)

        ranges: [{
            start:new Date(10/10/2018),
            end: new Date(15/10/2018),
        }],

    },
   {
        title:"morning shift",
        start: '10:00', // a start time (10am in this example)
        end: '15:00', // an end time (6pm in this example)

        ranges: [{
            start:new Date(10/09/2018),
            end: new Date(15/09/2018),
        }],

    }],

    }];

这里我有一个多维对象。

对于

apiData=[morningShift,10/09/2018,15/09/2018]

我已经映射了值及其工作成果

events : apiData.map(([start,end,title])=>({
                start: new Date(start),
                end: new Date(end+'T00:00:00-07:00'),
                title,
                className: 'bg-primary'})
              ), 

如何对多维对象执行此操作。我是js的初学者,有人可以帮助我吗?谢谢

0 个答案:

没有答案