From 04f77fedb2083269e8f707c4b703e4e0adf020ec Mon Sep 17 00:00:00 2001 From: meteorlxy Date: Sun, 27 Aug 2017 03:04:36 +0000 Subject: [PATCH] Add custom filter function --- src/components/Select.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/Select.vue b/src/components/Select.vue index 9b86837..e72ec7a 100644 --- a/src/components/Select.vue +++ b/src/components/Select.vue @@ -446,6 +446,21 @@ return option; } }, + + /** + * Callback to filter the search result the label text. + * @type {Function} + * @param {Object || String} option + * @param {String} label + * @param {String} search + * @return {Boolean} + */ + filterFunction: { + type: Function, + default(option, label, search) { + return label.toLowerCase().indexOf(search.toLowerCase()) > -1 + } + }, /** * An optional callback function that is called each time the selected @@ -854,7 +869,7 @@ if (typeof label === 'number') { label = label.toString() } - return label.toLowerCase().indexOf(this.search.toLowerCase()) > -1 + return this.filterFunction(option, label, this.search) }) if (this.taggable && this.search.length && !this.optionExists(this.search)) { options.unshift(this.search)