use the local array as data to realize the search function. Query according to the condition when the condition is available, and return all data when the condition is empty
this.users: local object array
search() {
console.log("search")
this.query = this.$refs.search.value;
if (this.query === "") {
this.$message({
showClose: true,
message: "",
type: "warning"
});
// this.users = this.user
this.users = Object.assign({},this.user)
} else {
this.$message({
showClose: true,
message: ":",
type: "success"
});
let result = []
result = this.users.filter(item => {
return item.name === this.query
})
this.users = result
}
},
now that the search condition is empty and no data is returned, how to modify it?