【发布时间】:2017-12-18 09:07:50
【问题描述】:
在我的 cal.vue 组件中,我有一个 fullcalendar 组件。在 cal.vue 中,我有一个名为 submit 的方法。在提交内部,我使用this.$refs.calendar 对fullcalendar 组件进行(成功)引用。但是,当我在提交函数中执行 this.$refs.calendar.$emit('refetchEvents'); 时,不会获取事件(我的事件不会在我的日历上更新)。为什么我的事件在提交时没有更新,我该如何更新它们?
以下是相关代码:
<template>
<div id="calendar" :navL="navLinks" :event-sources="eventSources" @event-selected="eventSelected" @event-created="eventCreated" :config="config" >
<button class="btn btn-secondary" v-on:click="submit()">
Submit
</button>
<full-calendar id="target" ref="calendar" :event-sources="eventSources" @event-selected="eventSelected" @day-click="click"@event-created="eventCreated" :config="config"></full-calendar>
</div>
</template>
<script>
const self = this;
export default {
name: 'calendar',
data() {
return {
eventSources: [
{
url: 'http://localhost:3000/getAppointments',
type: 'GET',
data: {
id: this.$store.getters.user
},
error: function() {
alert('there was an error while fetching events!');
},
}
],
};
},
methods: {
submit: function() {
console.log(this.$refs.calendar); //prints fullcalendar VUE component
this.$refs.calendar.$emit('refetchEvents'); //nothing appears to happen here
},
},
}
</script>
【问题讨论】:
-
什么是
full-calendar?包装 jQuery 插件的 Vue 组件?它仍然使用jQuery吗? -
full-calendar 是一个包装了 jQuery 插件 full-calendar 的 VUE 组件。我相信它使用 jQuery
-
你有链接吗?至少有两个 Vue 包装器。
-
calendar.vue 是上面代码所在的地方
-
如果 VUE 代码看起来没问题,可能是我使用的 vue-fullcalendar 包装器有问题。我会向他们发布问题,看看他们怎么说
标签: javascript vue.js fullcalendar