<FullCalendar id="calendar"
:options="calendarOptions"
/>
</section>
export default {
components: {
FullCalendar
},
data() {
return {
calendarOptions: {
plugins: [dayGridPlugin ,interactionPlugin, timeGridPlugin, listPlugin],
methods:{
newEvent(){
var theCalendar = document.getElementById("calendar");
var eventName = document.getElementById("Ename").value;
var sDate = document.getElementById("startDate").value;
var eDate = document.getElementById("endDate").value;
var type = document.getElementById("bookingType").value;
var number = document.getElementById("numberOfPeople").value;
//The addEvent can't be accessed, currently this function doesn't have access to the object Fullcalendar and because of that
//we can't use addEvent.
theCalendar.addEvent({
title: eventName,
start: sDate,
allDay: true
});
alert('Great. Now, update your database...');
}
}
Hello, my vue.JS code at the moment cant read undefined properties. I want to be able to populate the addEvent class with my calendar properties.
if you are trying to access the API
you should provide a ref on your calendar
<FullCalendar ref="fullCalendar" :options="calendarOptions" />
which can then be accessed as so
let calendarApi = this.$refs.fullCalendar.getApi()
calendarApi.next()
see here
however i suspect that you actually want is to access the calendarOptions object which is as simple as
this.calendarOptions.events
assuming you have defined the object as specified on the previous link
data() {
return {
calendarOptions: {
plugins: [ dayGridPlugin, interactionPlugin ],
events: [
{ title: 'event 1', date: '2019-04-01' },
{ title: 'event 2', date: '2019-04-02' }
]
}
}
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.