The problem is that you are binding the value i.e. using :value
instead of v-model
. So if you binding the value you have to assign the value to the data by yourself such that it causes reactiveness and hence updates the DOM.
If I with your approach of going with the binding value I would like to change my code something like this:
<el-date-picker
size="mini"
:value="filters.date_range"
@input="updateFilters"
value-format="yyyy-MM-dd"
format="MMMM dd, yyyy"
type="daterange"
align="right"
/>
Notice I have changed the filters.start_date
to filters_date_range
, as the value for type=daterange
takes an array with two items. something like
[startDate, endDate]
Another thing that you should notice is I removed the parameters from updateFilters
, because I want to receive the latest daterange whenever it gets selected.
Now in my handler function I just need to do:
updateFilters(data) {
this.$store.commit('panel/changeFilters', data)
this.filters.date_range = data
//data : [startDate, endDate]
}
And, it will update the DOM as soon as u change the picker value.
Another easier approach would be to use v-model
instead of :value
.
<el-date-picker
size="mini"
v-model="filters.date_range"
@input="updateFilters"
value-format="yyyy-MM-dd"
format="MMMM dd, yyyy"
type="daterange"
align="right"
/>
And it will update the DOM automatically, you don't have to set the value explicitly in the input handler, and can do any other stuff in the handler if you want to.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…