VueJSでフルカレンダーを使用しています。カレンダーで時間をクリックするたびにカスタムモーダルを開きます。しかし、フルカレンダーオブジェクトの外に別の関数を呼び出してモーダルを開く必要があります。フルカレンダー内でthis
を使用すると、そのオブジェクトとVueコンポーネントオブジェクトを参照するため、解決方法がわかりません。私はVueのコンポーネントオブジェクトを取得するための何らかの方法が必要で、ここで私は無駄内部からVueコンポーネントオブジェクトにアクセスするコンポーネント内に作成されたFullCalendarオブジェクト
export default {
name: 'MyComponent',
methods: {
myFunc() {
// should get called from inside fullCalendar below
this.$store.dispatch() // this.$store works here since `this` refers to Vue component
}
},
mounted() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listWeek'
},
navLinks: true,
eventLimit: true,
defaultView: 'agendaWeek',
editable: true,
selectable: true,
selectHelper: true,
select: function (start, end) {
console.log(this) // refers to Full Calendar object
console.log(this.$parent) // getting null, need to call function in vue component
console.log(this.myFunc()) // cannot do this since this will try to call a function in Full Calendar library
console.log(this.$parent.$store) // getting null, need to get store that I defined
}
}
}
よろしくお願いいたします。 – user3226932