[英]disabled dates not updating on view when we add through button click
I have used vue-hotel-date-picker its working fine.我已经使用了 vue-hotel-date-picker 它工作正常。 the issue is when using disabled dates props its disabled the dates first time when initializing and update on calendar.but when i update disabled dates array on any button click event it updates the disabled dates array but not reflect or render in view component.问题是当使用禁用日期道具时,它在日历上第一次初始化和更新时禁用了日期。但是当我在任何按钮单击事件上更新禁用日期数组时,它会更新禁用日期数组,但不会在视图组件中反映或呈现。 I have debug it through vuejs chrome extension.我已经通过 vuejs chrome 扩展对其进行了调试。
Here is an image when debugging这是调试时的图像
Here is my HTML Code这是我的HTML代码
<div class="box">
<h3>Check in only on saturday and minimum stay of 10 days</h3>
<DatePicker
DatePickerID="01"
:disabledDates = "disabledDates"
:enableCheckout="true"
:minNights="10"
:useDummyInputs="false"
placeholder="StartDate ► EndDate"
/>
</div>
<button @click="onChangeDisableDates()" > Change Disable Dates </button>
JS JS
<script>
import DatePicker from 'components/HotelDatePicker.vue';
export default {
components: {
DatePicker
},
data () {
return {
disabledDates : ['2017-08-18']
}
},
methods : {
onChangeDisableDates () {
this.disabledDates.push("2017-08-19");
}
}
};
</script>
I don't know how to figure out and solve this problem , it might be issue in this plugin,any help would be appreciated!我不知道如何找出并解决这个问题,这可能是这个插件的问题,任何帮助将不胜感激!
Write in computed: { } it will be updated then whenever there's a change.写入计算:{} 它将在发生更改时更新。
import DatePicker from 'components/HotelDatePicker.vue';
export default {
components: {
DatePicker
},
data() {
newDisabledDates: null
}
computed: {
disabledDates() {
// write your disable date change logic or fetch from any other data var
if (this.newDisabledDates === null) {
//default logic
return {
disabledDates: ['2017-08-18']
}
} else {
// this.newDisabledDates would have been updated here if button clicked
return {
disabledDates: this.newDisabledDates
}
}
}
},
methods: {
onChangeDisableDates() {
this.newDisabledDates.push("2017-08-19");
}
}
};
disabledDates(date) {
var gDate = date.getDate();
var gMonth = date.getMonth();
var gYear = date.getYear();
for(var i=0;i<(this.disabled.length);i++) {
var myarr = this.disabled[i].split("-");
if(gDate == parseInt(myarr[2]) && gMonth == parseInt(myarr[1]) && gYear == parseInt(myarr[0])) {
return true;
}
else {
return false;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.