0👍
Along the lines of this:
var test = {
computed: {
filteredRow: function() {
return this.model.data.filter(row => {
var value = row[this.query.search_column];
switch (this.query.search_operator) {
case "=": return value == this.query.search_input;
case ">": return value > this.query.search_input;
// ...
}
});
}
}
};
var vm = {
model: {data: [{a: 1}, {a: 2}] },
query: {search_column: "a", search_operator: ">", search_input: 1 }
};
console.log(test.computed.filteredRow.call(vm));
Missing: Type checks, type conversions, other operators, input sanitation.
- [Vuejs]-How to include promises in vuejs methods
- [Vuejs]-Eloquent Model not joining tables in the right order
Source:stackexchange.com