I have a component - https://pastebin.com/CFDfbfab . when something is typed in a field, the searchItems event is searchItems , which is passed through $emit to the main code and is called like this
searchItems: function (event) { let self = this if (this.timer !== null) { clearTimeout(this.timer._id) } if ((event.q).indexOf(',') === -1) { self.q = event.q this.timer = setTimeout(function () { alert(event.q) self.isLoading = true axios.post(self.$root.apiLink + 'geo/street', { q: event.q, lang: self.$ml.current, place: self.city }, { headers: {'Authorization': 'Bearer ' + (JSON.parse(localStorage.user).auth_key)} }).then(function (response) { self.isLoading = false self.citiesObject = response.data.data }) }, 1000) } else { self.citiesObject.forEach(function (e) { if (e.name.indexOf(event.q) === -1) { e.show = false } else { e.show = true } }) } } The component itself is connected as follows.
<select-address v-bind:show-address="select_address" v-on:closeAddress="selectLocation" v-on:searchItems="searchItems" v-bind:items="citiesObject" v-bind:showFavorite="showFavorite" v-on:saveAddress="saveAddress" ></select-address> The essence of the problem: if the field is empty and something to enter - it gives empty. And if something is already in the field - displays correctly. And because of this, when the user enters something for the first time - does not find anything
PS Sorry, I forgot to provide important information: a problem on the mobile phone. That is, I then collect this code in the application via cordova. And just there is a problem
inputelement, instead of thekeyupeventkeyupsubscribe to theinputevent - DmytryksearchStringnotnull, but with an empty string + as a test, it would be possible to hang thewatchonsearchString- Dmytrykwatch- now I will look for how to do it - Diefair