0
Calendar.vueコンポーネントにVUE.jsおよびFullCalendarアプリケーションを作成しています。問題が発生しました。このキーワードは要素を選択しません。コンポーネントのテンプレートは次のようになります。私のVUEアプリケーションで "this"キーワードはDOMオブジェクトを選択します
<template>
<div id="calendar" :event-sources="eventSources" @event-selected="eventSelected" @event-created="eventCreated" :config="config">
<button id="red" v-on:click="time">time</button>
<full-calendar id="target" ref="calendarC" :navLinks="true" :event-sources="eventSources" @event-selected="eventSelected" @day-click="click"@event-created="eventCreated" :config="config"></full-calendar>
</div>
</template>
そして、私の「この」キーワードが動作していない機能はここにある:
click: function(date, jsEvent, view) {
$("#red").css('background-color', 'red'); //here the jQuery works
$(this.selected).css('background-color', 'red');//here nothing happens
}
だから私は私のカレンダーの要素のボタンをクリックしたときidの赤が赤色に変わり、jQueryが正常に動作していることがわかります。しかし、私がクリックした要素は赤くならない。
ありがとうネイサン関連のSOの質問への回答に基づいていくつかのテストされていないコードは、以下を参照してください – Matt