Blame view

src/components/tooltip/tooltip.vue 1.81 KB
dce3e753   梁灏   add Tooltip compo...
1
  <template>
4b7138b9   梁灏   fixed some bugs
2
3
      <div :class="[prefixCls]" @mouseenter="handleShowPopper" @mouseleave="handleClosePopper">
          <div :class="[prefixCls + '-rel']" v-el:reference>
dce3e753   梁灏   add Tooltip compo...
4
5
              <slot></slot>
          </div>
4b7138b9   梁灏   fixed some bugs
6
7
8
9
          <div :class="[prefixCls + '-popper']" transition="fade" v-el:popper v-show="!disabled && visible">
              <div :class="[prefixCls + '-content']">
                  <div :class="[prefixCls + '-arrow']"></div>
                  <div :class="[prefixCls + '-inner']"><slot name="content">{{ content }}</slot></div>
dce3e753   梁灏   add Tooltip compo...
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
              </div>
          </div>
      </div>
  </template>
  <script>
      import Popper from '../base/popper';
      import { oneOf } from '../../utils/assist';
  
      const prefixCls = 'ivu-tooltip';
  
      export default {
          mixins: [Popper],
          props: {
              placement: {
                  validator (value) {
                      return oneOf(value, ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end']);
                  },
                  default: 'bottom'
              },
              content: {
                  type: [String, Number],
                  default: ''
              },
              delay: {
                  type: Number,
                  default: 0
              },
              disabled: {
                  type: Boolean,
                  default: false
              }
          },
          data () {
              return {
                  prefixCls: prefixCls
              }
          },
dce3e753   梁灏   add Tooltip compo...
47
48
49
          methods: {
              handleShowPopper() {
                  this.timeout = setTimeout(() => {
9699c270   梁灏   add Poptip component
50
                      this.visible = true;
dce3e753   梁灏   add Tooltip compo...
51
52
53
54
                  }, this.delay);
              },
              handleClosePopper() {
                  clearTimeout(this.timeout);
9699c270   梁灏   add Poptip component
55
                  this.visible = false;
dce3e753   梁灏   add Tooltip compo...
56
57
58
              }
          }
      }
d6342fe1   jingsam   fixed ie bug
59
  </script>