Commit 4e23e47c9494d1aa2be79d0fee94c0ab7c591770
1 parent
c1963810
update Cascader
Showing
2 changed files
with
9 additions
and
3 deletions
Show diff stats
src/components/cascader/cascader.vue
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | [selectPrefixCls + '-item-disabled']: item.disabled |
37 | 37 | }]" |
38 | 38 | v-for="(item, index) in querySelections" |
39 | - @click="handleSelectItem(index)">{{ item.label }}</li> | |
39 | + @click="handleSelectItem(index)" v-html="item.display"></li> | |
40 | 40 | </ul> |
41 | 41 | </div> |
42 | 42 | </div> |
... | ... | @@ -179,6 +179,7 @@ |
179 | 179 | selections.push({ |
180 | 180 | label: item.__label, |
181 | 181 | value: item.__value, |
182 | + display: item.__label, | |
182 | 183 | item: item, |
183 | 184 | disabled: !!item.disabled |
184 | 185 | }); |
... | ... | @@ -186,7 +187,10 @@ |
186 | 187 | } |
187 | 188 | } |
188 | 189 | getSelections(this.data); |
189 | - selections = selections.filter(item => item.label.indexOf(this.query) > -1); | |
190 | + selections = selections.filter(item => item.label.indexOf(this.query) > -1).map(item => { | |
191 | + item.display = item.display.replace(new RegExp(this.query, 'g'), `<span>${this.query}</span>`); | |
192 | + return item; | |
193 | + }); | |
190 | 194 | return selections; |
191 | 195 | } |
192 | 196 | }, |
... | ... | @@ -245,7 +249,6 @@ |
245 | 249 | const item = this.querySelections[index]; |
246 | 250 | |
247 | 251 | if (item.item.disabled) return false; |
248 | - // todo 还有bug,选完,删除后,失焦,不能回到上次选择的 | |
249 | 252 | this.query = ''; |
250 | 253 | this.$refs.input.currentValue = ''; |
251 | 254 | const oldVal = JSON.stringify(this.currentValue); | ... | ... |