From 4e23e47c9494d1aa2be79d0fee94c0ab7c591770 Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Thu, 11 May 2017 17:29:44 +0800 Subject: [PATCH] update Cascader --- src/components/cascader/cascader.vue | 9 ++++++--- src/styles/components/cascader.less | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/cascader/cascader.vue b/src/components/cascader/cascader.vue index f7111c4..7f4d788 100644 --- a/src/components/cascader/cascader.vue +++ b/src/components/cascader/cascader.vue @@ -36,7 +36,7 @@ [selectPrefixCls + '-item-disabled']: item.disabled }]" v-for="(item, index) in querySelections" - @click="handleSelectItem(index)">{{ item.label }} + @click="handleSelectItem(index)" v-html="item.display"> @@ -179,6 +179,7 @@ selections.push({ label: item.__label, value: item.__value, + display: item.__label, item: item, disabled: !!item.disabled }); @@ -186,7 +187,10 @@ } } getSelections(this.data); - selections = selections.filter(item => item.label.indexOf(this.query) > -1); + selections = selections.filter(item => item.label.indexOf(this.query) > -1).map(item => { + item.display = item.display.replace(new RegExp(this.query, 'g'), `${this.query}`); + return item; + }); return selections; } }, @@ -245,7 +249,6 @@ const item = this.querySelections[index]; if (item.item.disabled) return false; - // todo 还有bug,选完,删除后,失焦,不能回到上次选择的 this.query = ''; this.$refs.input.currentValue = ''; const oldVal = JSON.stringify(this.currentValue); diff --git a/src/styles/components/cascader.less b/src/styles/components/cascader.less index 1c8e03d..b837a54 100644 --- a/src/styles/components/cascader.less +++ b/src/styles/components/cascader.less @@ -71,6 +71,9 @@ } .select-item(@cascader-prefix-cls, @cascader-item-prefix-cls); + .ivu-select-item span{ + color: @error-color; + } &-dropdown{ padding: 5px 0; -- libgit2 0.21.4