Optimisation, si pas de caractere, on ne passe pas dans le filtre

This commit is contained in:
Christophe 2020-05-06 23:46:54 +02:00
parent ef82382f33
commit 99a6444c39
2 changed files with 11 additions and 12 deletions

View file

@ -109,14 +109,13 @@ let monTableau = {
}, },
computed: { computed: {
tableau: function () { tableau: function () {
return this.pagination( if (!this.search) {
this.table.filter((ligne) => { return this.pagination(this.table);
if (this.search) {
return Object.values(ligne).toString().toLowerCase().indexOf(this.search) < 0 ? false : true;
} else {
return true;
} }
}) return this.pagination(
this.table.filter((ligne) =>
Object.values(ligne).toString().toLowerCase().indexOf(this.search.toLowerCase()) < 0 ? false : true
)
); );
}, },
}, },

View file

@ -130,12 +130,12 @@ var monTableau = {
tableau: function tableau() { tableau: function tableau() {
var _this = this; var _this = this;
return this.pagination(this.table.filter(function (ligne) { if (!this.search) {
if (_this.search) { return this.pagination(this.table);
return Object.values(ligne).toString().toLowerCase().indexOf(_this.search) < 0 ? false : true;
} else {
return true;
} }
return this.pagination(this.table.filter(function (ligne) {
return Object.values(ligne).toString().toLowerCase().indexOf(_this.search.toLowerCase()) < 0 ? false : true;
})); }));
} }
}, },