Select add filter-by-label prop

This commit is contained in:
梁灏 2020-04-08 14:27:23 +08:00
parent 40c64eeb8b
commit ac618af2e6

View file

@ -273,6 +273,12 @@
default () { default () {
return !this.$IVIEW ? true : this.$IVIEW.capture; return !this.$IVIEW ? true : this.$IVIEW.capture;
} }
},
// 4.2.0
// label
filterByLabel: {
type: Boolean,
default: false
} }
}, },
mounted(){ mounted(){
@ -528,7 +534,7 @@
const nodeText = node.elm ? node.elm.textContent : node.text; const nodeText = node.elm ? node.elm.textContent : node.text;
return `${str} ${nodeText}`; return `${str} ${nodeText}`;
}, '') || ''; }, '') || '';
const stringValues = JSON.stringify([value, label, textContent]); const stringValues = this.filterByLabel ? JSON.stringify([label]) : JSON.stringify([value, label, textContent]);
const query = this.query.toLowerCase().trim(); const query = this.query.toLowerCase().trim();
return stringValues.toLowerCase().includes(query); return stringValues.toLowerCase().includes(query);
}, },