mafortis
mafortis

Reputation: 7128

Vue search while typing

I have search field and I wish to have the results in real-time,

I have no issue with returning data or showing data but I need a way to send input value to back-end while user is typing it.

Code

HTML

<el-input placeholder="Type something" v-model="search">
  <i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>

Script

data() {
    return {
        search: '' // getting data of input field
    }
},

one

I've tried to compute it but it didn't return data

computed : {
    searchSubmit: {
        get: function () {
            console.log(this.search);
        }
    }
},

Any idea?

Upvotes: 1

Views: 604

Answers (1)

Dvdgld
Dvdgld

Reputation: 2164

For side effects as calling backend you can use Watchers.

 watch: {
  search(value) {
    yourApiCall(value)
  }
 }

Upvotes: 2

Related Questions