Blame view

src/components/divider/divider.vue 1.8 KB
b26389a0   xiaofengsha   * 对照AntDesign,实现了...
1
  <template>
e9ad2b7a   梁灏   update Divider
2
3
4
5
6
      <div :class="classes">
          <span v-if="hasSlot" :class="slotClasses">
              <slot></slot>
          </span>
      </div>
b26389a0   xiaofengsha   * 对照AntDesign,实现了...
7
8
9
  </template>
  
  <script>
e9ad2b7a   梁灏   update Divider
10
      import {oneOf} from '../../utils/assist';
b26389a0   xiaofengsha   * 对照AntDesign,实现了...
11
  
e9ad2b7a   梁灏   update Divider
12
      const prefixCls = 'ivu-divider';
b26389a0   xiaofengsha   * 对照AntDesign,实现了...
13
  
e9ad2b7a   梁灏   update Divider
14
15
16
17
18
19
20
21
22
23
24
25
      export default {
          name: 'Divider',
          props: {
              type: {
                  type: String,
                  default: 'horizontal',
                  validator (value) {
                      return oneOf(value, ['horizontal', 'vertical']);
                  }
              },
              orientation: {
                  type: String,
a0141266   梁灏   update Divider style
26
                  default: 'center',
e9ad2b7a   梁灏   update Divider
27
                  validator (value) {
a0141266   梁灏   update Divider style
28
                      return oneOf(value, ['left', 'right', 'center']);
e9ad2b7a   梁灏   update Divider
29
30
31
32
33
                  }
              },
              dashed: {
                  type: Boolean,
                  default: false,
f308dcac   梁灏   fixed #4415
34
35
36
37
38
39
              },
              size: {
                  validator (value) {
                      return oneOf(value, ['small', 'default']);
                  },
                  default: 'default'
e9ad2b7a   梁灏   update Divider
40
41
42
43
44
45
46
47
48
49
              }
          },
          computed: {
              hasSlot() {
                  return !!this.$slots.default;
              },
              classes() {
                  return [
                      `${prefixCls}`,
                      `${prefixCls}-${this.type}`,
f308dcac   梁灏   fixed #4415
50
                      `${prefixCls}-${this.size}`,
e9ad2b7a   梁灏   update Divider
51
                      {
9cdfb2e2   梁灏   fix #5135
52
                          [`${prefixCls}-with-text`]: this.hasSlot && this.orientation === 'center',
e9ad2b7a   梁灏   update Divider
53
54
55
56
57
58
59
60
                          [`${prefixCls}-with-text-${this.orientation}`]: this.hasSlot,
                          [`${prefixCls}-dashed`]: !!this.dashed
                      }
                  ];
              },
              slotClasses() {
                  return [
                      `${prefixCls}-inner-text`,
77376451   梁灏   fixed #3568
61
                  ];
e9ad2b7a   梁灏   update Divider
62
              }
b26389a0   xiaofengsha   * 对照AntDesign,实现了...
63
          }
77376451   梁灏   fixed #3568
64
      };
e9ad2b7a   梁灏   update Divider
65
  </script>