Commit 1363abdcf99708e3cf3207aae47a01273844ea8d
1 parent
fae238f5
fixed #178
assign query to child's label
Showing
2 changed files
with
13 additions
and
17 deletions
Show diff stats
src/components/select/select.vue
| @@ -447,7 +447,7 @@ | @@ -447,7 +447,7 @@ | ||
| 447 | if (model !== '') { | 447 | if (model !== '') { |
| 448 | this.findChild((child) => { | 448 | this.findChild((child) => { |
| 449 | if (child.value === model) { | 449 | if (child.value === model) { |
| 450 | - this.query = child.searchLabel; | 450 | + this.query = child.label === undefined ? child.searchLabel : child.label; |
| 451 | } | 451 | } |
| 452 | }); | 452 | }); |
| 453 | } | 453 | } |
| @@ -574,7 +574,7 @@ | @@ -574,7 +574,7 @@ | ||
| 574 | if (this.filterable) { | 574 | if (this.filterable) { |
| 575 | this.findChild((child) => { | 575 | this.findChild((child) => { |
| 576 | if (child.value === value) { | 576 | if (child.value === value) { |
| 577 | - this.query = child.searchLabel; | 577 | + this.query = child.label === undefined ? child.searchLabel : child.label; |
| 578 | } | 578 | } |
| 579 | }); | 579 | }); |
| 580 | } | 580 | } |
test/routers/select.vue
| @@ -2,12 +2,12 @@ | @@ -2,12 +2,12 @@ | ||
| 2 | <Row> | 2 | <Row> |
| 3 | <i-col span="12" style="padding-right:10px"> | 3 | <i-col span="12" style="padding-right:10px"> |
| 4 | <i-select :model.sync="model11" filterable> | 4 | <i-select :model.sync="model11" filterable> |
| 5 | - <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option> | 5 | + <i-option v-for="item in cityList" :value="item.value" :label="item.label"><span>{{ item.label }}</span><span>{{ item.des }}</span></i-option> |
| 6 | </i-select> | 6 | </i-select> |
| 7 | </i-col> | 7 | </i-col> |
| 8 | <i-col span="12"> | 8 | <i-col span="12"> |
| 9 | <i-select :model.sync="model12" filterable multiple> | 9 | <i-select :model.sync="model12" filterable multiple> |
| 10 | - <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option> | 10 | + <i-option v-for="item in cityList" :value="item.value" :label="item.label"><span>{{ item.label }}</span><span>{{ item.des }}</span></i-option> |
| 11 | </i-select> | 11 | </i-select> |
| 12 | </i-col> | 12 | </i-col> |
| 13 | </Row> | 13 | </Row> |
| @@ -19,30 +19,26 @@ | @@ -19,30 +19,26 @@ | ||
| 19 | cityList: [ | 19 | cityList: [ |
| 20 | { | 20 | { |
| 21 | value: 'beijing', | 21 | value: 'beijing', |
| 22 | - label: '北京市' | 22 | + label: '北京市', |
| 23 | + des: '帝都' | ||
| 23 | }, | 24 | }, |
| 24 | { | 25 | { |
| 25 | value: 'shanghai', | 26 | value: 'shanghai', |
| 26 | - label: '上海市' | 27 | + label: '上海市', |
| 28 | + des: '魔都' | ||
| 27 | }, | 29 | }, |
| 28 | { | 30 | { |
| 29 | value: 'shenzhen', | 31 | value: 'shenzhen', |
| 30 | - label: '深圳市' | ||
| 31 | - }, | ||
| 32 | - { | ||
| 33 | - value: 'hangzhou', | ||
| 34 | - label: '杭州市' | ||
| 35 | - }, | ||
| 36 | - { | ||
| 37 | - value: 'nanjing', | ||
| 38 | - label: '南京市' | 32 | + label: '深圳市', |
| 33 | + des: '渔村' | ||
| 39 | }, | 34 | }, |
| 40 | { | 35 | { |
| 41 | value: 'chongqing', | 36 | value: 'chongqing', |
| 42 | - label: '重庆市' | 37 | + label: '重庆市', |
| 38 | + des: '山城' | ||
| 43 | } | 39 | } |
| 44 | ], | 40 | ], |
| 45 | - model11: 'beijing', | 41 | + model11: '', |
| 46 | model12: ['beijing', 'shanghai'] | 42 | model12: ['beijing', 'shanghai'] |
| 47 | } | 43 | } |
| 48 | } | 44 | } |