- just came into contact with the problem of Vue, doing table search
<el-input
class="serch-input"
placeholder=""
suffix-icon="el-icon-search"
v-model="search"
ref="inputvalue"
@change.native="searchTable()">
</el-input>
searchTable() {
const val = this.$refs.inputvalue.value
let resultData = this.tableData.filter(data=>{
if( data.title.indexOf(val) > -1){
return true
}
})
console.log(resultData)
this.tableData = resultData
this.total = this.tableData.length
}
The code written by - is shown above, but now there is a problem with the search.
-
After the
- search is completed, delete the value in input, and the data of the table remains unchanged. I guess it"s the reason for the this.tableData = resultData assignment, but I don"t know how to change it. Ask for advice.
- or is there any other good way to implement it?