admin管理员组文章数量:1356951
I'm using the FullCalendar library for Vue and I have a perfectly working calendar, but I can't get clicking on date/calendar events to work.
I have the calendar in the template:
<full-calendar @dateClick="handleDateClick" :config="config" :events="events"/></full-calendar>
and my vue code:
export default {
data () {
return {
events: [
title: 'My Event',
start: '2010-01-01'
],
config: {
defaultView: 'month',
editable:true,
eventRender: function(event, element) {
console.log(event)
}
},
}
},
methods: {
handleDateClick(arg) {
alert(arg.date)
},
},
}
This seems to match the docs but I'm not getting the alert. I'm just trying to make it so that I have the functionality in place so that I can tie each event click to a modal with that event's details.
What exactly am I doing wrong here?
I'm using the FullCalendar library for Vue https://fullcalendar.io/docs/vue and I have a perfectly working calendar, but I can't get clicking on date/calendar events to work.
I have the calendar in the template:
<full-calendar @dateClick="handleDateClick" :config="config" :events="events"/></full-calendar>
and my vue code:
export default {
data () {
return {
events: [
title: 'My Event',
start: '2010-01-01'
],
config: {
defaultView: 'month',
editable:true,
eventRender: function(event, element) {
console.log(event)
}
},
}
},
methods: {
handleDateClick(arg) {
alert(arg.date)
},
},
}
This seems to match the docs but I'm not getting the alert. I'm just trying to make it so that I have the functionality in place so that I can tie each event click to a modal with that event's details.
What exactly am I doing wrong here?
Share Improve this question asked Sep 9, 2019 at 11:59 Geoff_SGeoff_S 5,1057 gold badges58 silver badges168 bronze badges 2- any errors in your console? – ADyson Commented Sep 9, 2019 at 14:44
- No errors at all, that's one thing that doesn't make sense – Geoff_S Commented Sep 9, 2019 at 14:54
2 Answers
Reset to default 4You need to add selectable:true as the default is false. And you need the interactionPlugin as well.
https://fullcalendar.io/docs/selectable https://fullcalendar.io/docs/plugin-index
import interactionPlugin from '@fullcalendar/interaction'
config:{
...
selectable:true,
plugins:[interactionPlugin]
}
I have the following setup and it allows me to click and click and drag. Your code is only missing @select=""
.
<template>
<FullCalendar
defaultView="dayGridMonth"
:plugins="calendarPlugins"
:events="events"
:selectable="true"
@select="handleSelect"
@clickDate="handleDateClick"
/>
</template>
<script>
/* eslint-disable */
import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'
import interactionPlugin from '@fullcalendar/interaction';
export default {
name: 'Home',
ponents: {
FullCalendar
},
mounted(){
},
data () {
return {
events: [{title:'Something', start:'2019-09-12'}],
calendarPlugins:[dayGridPlugin, interactionPlugin]
}
},
methods:{
handleDateClick(e){
console.log(e);
},
handleSelect(e){
console.log(e);
}
}
}
</script>
<style lang='scss'>
@import '~@fullcalendar/core/main.css';
@import '~@fullcalendar/daygrid/main.css';
@import '~@fullcalendar/timegrid/main.css';
@import '~@fullcalendar/list/main.css';
</style>
本文标签: javascriptVue FullCalendarsetting click eventStack Overflow
版权声明:本文标题:javascript - Vue FullCalendar, setting click event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743953970a2567801.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论