瀏覽代碼

Select: remove empty option item when default value is null in single mode (#11731)

kratsstark 7 年之前
父節點
當前提交
9355bd3180
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      packages/select/src/select.vue

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

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