Commit 9c2c48dcee8d607c11ef521a9e692b67f355d32c

Authored by 刘汉宸
1 parent 9aae7566

fix: 修复Select组件无法加入空字符串值的问题

Showing 1 changed file with 4 additions and 3 deletions   Show diff stats
packages/select/index.vue
... ... @@ -243,10 +243,11 @@ export default {
243 243 fixOptions(list) {
244 244 let hash = {};
245 245 return [...this.options, ...list].reduce((result, item) => {
246   - if (!hash[item[this.valueKey]]) {
  246 + let hashKey = `${item[this.valueKey]}` || '_empty';
  247 + if (!hash[hashKey]) {
247 248 // 如果当前元素的key值没有在hash对象里,则可放入最终结果数组
248   - hash[item[this.valueKey]] = true; // 把当前元素key值添加到hash对象
249   - item[this.valueKey] && item[this.labelKey] && result.push(item); // 把当前元素放入结果数组
  249 + hash[hashKey] = true; // 把当前元素key值添加到hash对象
  250 + item[this.labelKey] && result.push(item); // 把当前元素放入结果数组
250 251 }
251 252 return result; // 返回结果数组
252 253 }, []);
... ...