5
5
<script >
6
6
import Calendar from ' tui-calendar' ;
7
7
8
- const calendarEvents = [
9
- ' afterRenderSchedule' ,
10
- ' beforeCreateSchedule' ,
11
- ' beforeDeleteSchedule' ,
12
- ' beforeUpdateSchedule' ,
13
- ' clickDayname' ,
14
- ' clickSchedule' ,
15
- ' clickTimezonesCollapseBtn'
16
- ];
17
-
18
8
const scheduleNeedProp = [
19
9
' start' ,
20
10
' category'
@@ -161,11 +151,6 @@ export default {
161
151
this .calendarInstance .setOptions ({isReadOnly: newValue});
162
152
}
163
153
},
164
- data () {
165
- return {
166
- calendarInstance: null
167
- };
168
- },
169
154
mounted () {
170
155
this .calendarInstance = new Calendar (this .$refs .tuiCalendar , {
171
156
defaultView: this .view ,
@@ -187,18 +172,18 @@ export default {
187
172
this .addEventListeners ();
188
173
this .reflectSchedules ();
189
174
},
190
- destroyed () {
191
- calendarEvents . forEach ( event => this .calendarInstance .off (event ) );
175
+ beforeDestroy () {
176
+ this .calendarInstance .off ();
192
177
this .calendarInstance .destroy ();
193
178
},
194
179
methods: {
195
180
cloneData (data ) {
196
181
return JSON .parse (JSON .stringify (data));
197
182
},
198
183
addEventListeners () {
199
- calendarEvents . forEach ( event => {
200
- this .calendarInstance .on (event , (... args ) => this .$emit (event , ... args));
201
- }) ;
184
+ for ( const eventName of Object . keys ( this . $listeners )) {
185
+ this .calendarInstance .on (eventName , (... args ) => this .$emit (eventName , ... args));
186
+ };
202
187
},
203
188
reflectSchedules () {
204
189
if (this .schedules .length > 0 ) {
0 commit comments