35
rated 0 times
[
40]
[
5]
/ answers: 1 / hits: 24582
/ 6 Years ago, wed, february 21, 2018, 12:00:00
I'm using the keydown/keyup events which call a javascript function that prints the value of input box to the console (and also the value of the currentTarget field of the event), and I am noticing it is a character late. For example, if I type hello into the input box, I only see hell in the console, until I press another key and then I see hello, even though by this point I've typed hello1. Why is this? And is there anyway around it?
Here's the HTML:
<input type=text class=form__field v-model=keywords v-on:keyup.enter=queryForKeywords v-on:keydown=queryForKeywords>
And the JS:
queryForKeywords: function(event) {
var self = this;
if (this.keywords.length > 2) {
console.log(keywords value: + this.keywords);
console.log(event value: + event.currentTarget.value);
}
More From » vue.js