Vuetify: 1.4.1
Last working version: 1.4.0
Vue: 2.5.21
Browsers: Chromium 71.0.3578.80
OS: Ubuntu undefined
<template>
<v-select
v-model="value"
:items="items"
@change="printValue()"
></v-select>
</template>
<script>
export default {
data: () => ({
value: null,
items: ['Foo', 'Bar', 'Fizz', 'Buzz']
}),
methods: {
printValue() {
console.log(this.value);
}
}
}
</script>
When I selected Foo, it should console.log 'Foo',
And When I selected Bar, it should console.log 'Bar'.
When I selected Foo, it actually console.log 'null',
And When I selected Bar, it actually console.log 'Foo'.
A better reproduction of your issue https://codepen.io/johnjleider/pen/JwwMoB
@johnleider thanks, man. It's my first time to use sandbox app.
We also figured out, that the change event returns the previously selected instead of the current selected.
Not a bug.
@change="printValue"
methods: {
printValue(val) {
alert(val)
}
}
or
- @change="printValue"
watch: {
value (val) {
alert(val)
}
}
Ah! We also made this mistake of accessing the binded property in change function. Here is a sandbox that shows the different values. nextTick() can help, but i think better way is to use the functions parameter.
https://codesandbox.io/s/vvjr2nylj0
thank KaelWD ;-)
@mascit13 thanks
This does actually seem to be a regression, caused by #6054 changing the event order. You should still be using the event value instead, but maybe this needs to be fixed to avoid breaking existing applications that're using poor practises.
Just just stumbled upon this change in behaviour in 1.4 too. I fail to see why a variable bound to a v-model should be updated _after_ the change event is fired, because that's exactly the thing that changed. Best regards from layer 8 :P
Most helpful comment
Ah! We also made this mistake of accessing the binded property in change function. Here is a sandbox that shows the different values. nextTick() can help, but i think better way is to use the functions parameter.
https://codesandbox.io/s/vvjr2nylj0
thank KaelWD ;-)