我已綁定的陣列events
含有事件以填充在調度程序(調度DHTMLX)的成分標籤<scheduler>
數據後不更新。但是,DOM不會自動刷新當由創建vue實例時觸發的getEvents
方法檢索到數據時。Vuejs DOM取出
有2個VUE文件和我一起工作:App.vue包含主應用程序成分和含有調度組件Scheduler.vue文件。
的事情是,當我修改的東西在Scheduler.vue文件並保存它,它正確地採取更新events
陣列考慮。 當DOM安裝在調度程序組件中時,調度程序解析events
prop中的數據。
因此是有什麼我可以做的就是更新的陣列?
這裏是App.vue:
<template>
<div id="app">
<div class="container">
<scheduler v-bind:events="events"></scheduler>
</div>
</div>
</template>
<script>
import Scheduler from './components/Scheduler.vue';
import auth from './components/auth/index'
import data from './components/data/index'
export default {
name: 'app',
components: {
Scheduler
},
data() {
return {
events: []
}
},
created() {
this.getEvents();
},
watch: {
events: function(value) {
console.log('updated');
}
},
methods: {
async getEvents() {
try {
const token = await auth.getToken(this);
const thattoken = await auth.getThatToken(this, token);
await data.getOgustData(this, token, '/calendar/events', 307310564, this.events);
} catch (e) {
console.log(e);
}
},
}
}
</script>
這裏是Scheduler.vue:
<template lang="html">
<div ref="scheduler_here" class="dhx_cal_container" style='width:100%; height:700px;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button"> </div>
<div class="dhx_cal_next_button"> </div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
</div>
<div class="dhx_cal_header"></div>
<div class="dhx_cal_data"></div>
</div>
</template>
<script>
import 'dhtmlx-scheduler'
import 'dhtmlx-scheduler/codebase/locale/locale_fr';
import 'dhtmlx-scheduler/codebase/ext/dhtmlxscheduler_readonly.js';
export default {
name: 'scheduler',
props: {
events: {
type: Array,
default() {
return [{
id: '',
text: '',
start_date: '',
end_date: '',
}]
}
}
},
mounted() {
scheduler.config.xml_date = '%Y-%m-%d %H:%i';
// disable left buttons on lightbox
scheduler.config.buttons_left = [];
// enable cancel button on lightbox's right wing
scheduler.config.buttons_right = ['dhx_cancel_btn'];
// changing cancel button label
scheduler.locale.labels['icon_cancel'] = 'Fermer';
// hide lightbox in month view
scheduler.config.readonly_form = true;
// hide select bar in day and week views
scheduler.config.select = false;
scheduler.config.lightbox.sections = [
{
name: "description",
height: 20,
map_to: "text",
type: "textarea",
focus: true
}
];
scheduler.init(this.$refs.scheduler_here, new Date(), 'month');
scheduler.parse(this.$props.events, 'json');
},
}
</script>
<style lang="css" scoped>
@import "~dhtmlx-scheduler/codebase/dhtmlxscheduler.css";
</style>
謝謝您的回答。我創建了'eventsArr'道具,因爲我無法弄清楚爲什麼道具沒有在DOM中更新。 – jctrebalag
查看最新回答,@ jctrebalag –
謝謝您的回答。我創建了'eventsArr'道具,因爲我無法弄清楚爲什麼'events'道具沒有在DOM中更新。所以我讓'events'指向'eventsArr'來查看是否考慮了更新。對不起,誤解(我編輯了App.vue的代碼,只讓'events'支持使用)。儘管在我的調度程序組件中修改某些內容時,只考慮了「events」數組。 – jctrebalag