如何在nativescript-ui-calendar上的事件数据中添加ID?

时间:2019-12-10 11:52:58

标签: nativescript nativescript-vue nativescript-telerik-ui

我可以为活动添加标题,开始和结束日期以及颜色。但是,如何为事件添加ID?当我点击某个事件时,我会获取此数据,并且需要获取该事件的ID,以便可以在另一页上呈现该事件。

                              `==== object dump start ====
                             _ios: <TKCalendarEvent: 0x2823c1c20>
                             constructor: ()
                              ios: <TKCalendarEvent: 0x2823c1c20>
                             _setIsAllDay: ()
                             _getIsAllDay: ()
                             _setEndDate: ()
                             _getEndDate: ()
                             _setStartDate: ()
                             _getStartDate: ()
                             _setTitle: ()
                             _getTitle: ()
                             _setEventColor: ()
                            _getEventColor: ()
                            android: undefined
                            title: Test
                            startDate: Sun Dec 15 2019 15:43:00 GMT+0100 (CET)
                            endDate: Sun Dec 15 2019 15:43:00 GMT+0100 (CET)
                            isAllDay: false
                            eventColor: #C8BC1AD6
                            ==== object dump end ====
                            `

这就是我获取的数据,我需要能够为事件设置ID,然后在获取此数据时获取ID。

这是我添加标题,开始日期,结束日期和颜色的方式:

`event = new calendarModule.CalendarEvent(taskArray[i].title, 
 startDate, endDate, false, colors[i * 10 % (colors.length - 1)]);`

1 个答案:

答案 0 :(得分:0)

您可以扩展CalendarEvent来添加ID和您喜欢的任何属性。请参阅documentation (Vue) here。它是用TypeScript编写的,如果您在JS项目中配置了Transpiller或将其翻译为JS(只需删除类型,运行时已经支持E6语法,那么您就可以了),就可以按原样使用。