[英]'Cannot read properties of undefined events' Vue.JS
<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.您好,我的 vue.JS 代码目前无法读取未定义的属性。 I want to be able to populate the addEvent class with my calendar properties.
我希望能够使用我的日历属性填充 addEvent 类。
if you are trying to access the API如果您尝试访问 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()
however i suspect that you actually want is to access the calendarOptions object which is as simple as但是我怀疑您实际上想要的是访问 calendarOptions 对象,它很简单
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' }
]
}
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.