Blame view

node_modules/element-ui/packages/result/src/index.vue 1.41 KB
7820380e   “wangming”   1
1
2
3
4
5
6
7
8
9
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  <template>
    <div class="el-result">
      <div class="el-result__icon">
        <slot name="icon">
          <component :is="iconElement" :class="iconElement" />
        </slot>
      </div>
      <div v-if="title || $slots.title" class="el-result__title">
        <slot name="title">
          <p>{{ title }}</p>
        </slot>
      </div>
      <div v-if="subTitle || $slots.subTitle" class="el-result__subtitle">
        <slot name="subTitle">
          <p>{{ subTitle }}</p>
        </slot>
      </div>
      <div v-if="$slots.extra" class="el-result__extra">
        <slot name="extra"></slot>
      </div>
    </div>
  </template>
  <script>
  import IconSuccess from './icon-success.vue';
  import IconError from './icon-error.vue';
  import IconWarning from './icon-warning.vue';
  import IconInfo from './icon-info.vue';
  
  const IconMap = {
    success: 'icon-success',
    warning: 'icon-warning',
    error: 'icon-error',
    info: 'icon-info'
  };
  
  export default {
    name: 'ElResult',
    components: {
      [IconSuccess.name]: IconSuccess,
      [IconError.name]: IconError,
      [IconWarning.name]: IconWarning,
      [IconInfo.name]: IconInfo
    },
    props: {
      title: {
        type: String,
        default: ''
      },
      subTitle: {
        type: String,
        default: ''
      },
      icon: {
        type: String,
        default: 'info'
      }
    },
    computed: {
      iconElement() {
        const icon = this.icon;
        return icon && IconMap[icon] ? IconMap[icon] : 'icon-info';
      }
    }
  };
  </script>