Blame view

src/components/grid/row.vue 2.06 KB
7fa943eb   梁灏   init
1
  <template>
d2203972   梁灏   add gutter to Row...
2
      <div :class="classes" :style="styles">
7fa943eb   梁灏   init
3
4
5
6
7
8
9
10
11
          <slot></slot>
      </div>
  </template>
  <script>
      import { oneOf } from '../../utils/assist';
  
      const prefixCls = 'ivu-row';
  
      export default {
34ee7b4a   梁灏   support Tree & ad...
12
          name: 'Row',
7fa943eb   梁灏   init
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
          props: {
              type: {
                  validator (value) {
                      return oneOf(value, ['flex']);
                  }
              },
              align: {
                  validator (value) {
                      return oneOf(value, ['top', 'middle', 'bottom']);
                  }
              },
              justify: {
                  validator (value) {
                      return oneOf(value, ['start', 'end', 'center', 'space-around', 'space-between']);
                  }
              },
d2203972   梁灏   add gutter to Row...
29
30
31
32
              gutter: {
                  type: Number,
                  default: 0
              },
7fa943eb   梁灏   init
33
34
35
36
37
              className: String
          },
          computed: {
              classes () {
                  return [
7fa943eb   梁灏   init
38
                      {
9d844d53   梁灏   fixed Layout bug
39
                          [`${prefixCls}`]: !this.type,
7fa943eb   梁灏   init
40
41
42
43
44
                          [`${prefixCls}-${this.type}`]: !!this.type,
                          [`${prefixCls}-${this.type}-${this.align}`]: !!this.align,
                          [`${prefixCls}-${this.type}-${this.justify}`]: !!this.justify,
                          [`${this.className}`]: !!this.className
                      }
b0893113   jingsam   :art: add eslint
45
                  ];
d2203972   梁灏   add gutter to Row...
46
47
48
49
50
51
52
              },
              styles () {
                  let style = {};
                  if (this.gutter !== 0) {
                      style = {
                          marginLeft: this.gutter / -2 + 'px',
                          marginRight: this.gutter / -2 + 'px'
b0893113   jingsam   :art: add eslint
53
                      };
d2203972   梁灏   add gutter to Row...
54
55
56
                  }
  
                  return style;
7fa943eb   梁灏   init
57
              }
d2203972   梁灏   add gutter to Row...
58
59
60
61
62
63
64
65
66
67
68
69
70
71
          },
          methods: {
              updateGutter (val) {
                  this.$children.forEach((child) => {
                      if (val !== 0) {
                          child.gutter = val;
                      }
                  });
              }
          },
          watch: {
              gutter (val) {
                  this.updateGutter(val);
              }
7fa943eb   梁灏   init
72
          }
b0893113   jingsam   :art: add eslint
73
74
      };
  </script>