浏览代码

Select: remove redundant empty option item when set default value undefined single select mode (#15007) (#15111)

susiwen8 6 年之前
父节点
当前提交
c42716000c
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      packages/select/src/select.vue

+ 2 - 1
packages/select/src/select.vue

@@ -510,6 +510,7 @@
         let option;
         const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
         const isNull = Object.prototype.toString.call(value).toLowerCase() === '[object null]';
+        const isUndefined = Object.prototype.toString.call(value).toLowerCase() === '[object undefined]';
 
         for (let i = this.cachedOptions.length - 1; i >= 0; i--) {
           const cachedOption = this.cachedOptions[i];
@@ -522,7 +523,7 @@
           }
         }
         if (option) return option;
-        const label = (!isObject && !isNull)
+        const label = (!isObject && !isNull && !isUndefined)
           ? value : '';
         let newOption = {
           value: value,