소스 검색

improve docs

baiyaaaaa 8 년 전
부모
커밋
d0097cec14
5개의 변경된 파일13개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 1
      examples/docs/en-US/cascader.md
  2. 1 1
      examples/docs/zh-CN/cascader.md
  3. 1 1
      examples/docs/zh-CN/select.md
  4. 9 3
      packages/cascader/src/main.vue
  5. 1 4
      packages/cascader/src/menu.vue

+ 1 - 1
examples/docs/en-US/cascader.md

@@ -473,7 +473,7 @@ Search and select options directly.
 |---------- |-------------------- |---------|-------------  |-------- |
 | options   | data source of the options | array  |       —        |     —    |
 | value | selected value   | array | — |     —    |
-| popup-class | className of popup overlay   | string |      —         |     —    |
+| popper-class | className of popup overlay   | string |      —         |     —    |
 | placeholder | input placeholder | string    |      —         |     —    |
 | disabled  | 是否禁用    | boolean   |  — | false   |
 | clearable  | whether allow clear    | boolean   |  — | false   |

+ 1 - 1
examples/docs/zh-CN/cascader.md

@@ -477,7 +477,7 @@
 |---------- |-------- |---------- |-------------  |-------- |
 | options   | 可选项数据源 | array  |       —        |     —    |
 | value | 指定选中项   | array | — |     —    |
-| popup-class | 自定义浮层类名   | string |      —         |     —    |
+| popper-class | 自定义浮层类名   | string |      —         |     —    |
 | placeholder | 输入框占位文本 | string    |      —         |     —    |
 | disabled  | 是否禁用    | boolean   |  — | false   |
 | clearable  | 是否支持清除    | boolean   |  — | false   |

+ 1 - 1
examples/docs/zh-CN/select.md

@@ -215,7 +215,7 @@
           value: '选项5',
           label: '北京烤鸭'
         }],
-        value2: '选项2'
+        value2: ''
       }
     }
   }

+ 9 - 3
packages/cascader/src/main.vue

@@ -146,6 +146,7 @@ export default {
 
       this.menu.value = this.currentValue.slice(0);
       this.menu.visible = true;
+      this.menu.options = this.options;
       this.menu.$on('pick', this.handlePick);
       this.updatePopper();
       this.$nextTick(_ => {
@@ -153,18 +154,20 @@ export default {
       });
     },
     hideMenu() {
-      this.menu.visible = false;
       this.inputValue = '';
+      this.menu.visible = false;
     },
     handlePick(value, close = true) {
       this.currentValue = value;
       this.$emit('input', value);
       this.$emit('change', value);
+
       if (close) {
         this.menuVisible = false;
       }
     },
     handleInputChange(value) {
+      if (!this.menuVisible) return;
       const flatOptions = this.flatOptions;
 
       if (!value) {
@@ -228,9 +231,12 @@ export default {
       this.menuVisible = false;
     },
     handleClick() {
-      if (!this.disabled) {
-        this.menuVisible = !this.menuVisible;
+      if (this.disabled) return;
+      if (this.filterable) {
+        this.menuVisible = true;
+        return;
       }
+      this.menuVisible = !this.menuVisible;
     }
   }
 };

+ 1 - 4
packages/cascader/src/menu.vue

@@ -34,7 +34,6 @@
         cache: false,
         get() {
           const activeValue = this.activeValue;
-          let options = this.options;
 
           const loadActiveOptions = (options, activeOptions = []) => {
             const level = activeOptions.length;
@@ -49,9 +48,7 @@
             return activeOptions;
           };
 
-          const result = loadActiveOptions(options);
-
-          return result;
+          return loadActiveOptions(this.options);
         }
       }
     },