index.vue
1.05 KB
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
<template>
<div class="el-empty">
<div class="el-empty__image" :style="imageStyle">
<img v-if="image" :src="image" ondragstart="return false">
<slot v-else name="image">
<img-empty />
</slot>
</div>
<div class="el-empty__description">
<slot v-if="$slots.description" name="description"></slot>
<p v-else>{{ emptyDescription }}</p>
</div>
<div v-if="$slots.default" class="el-empty__bottom">
<slot></slot>
</div>
</div>
</template>
<script>
import ImgEmpty from './img-empty.vue';
import { t } from 'element-ui/src/locale';
export default {
name: 'ElEmpty',
components: {
[ImgEmpty.name]: ImgEmpty
},
props: {
image: {
type: String,
default: ''
},
imageSize: Number,
description: {
type: String,
default: ''
}
},
computed: {
emptyDescription() {
return this.description || t('el.empty.description');
},
imageStyle() {
return {
width: this.imageSize ? `${this.imageSize}px` : ''
};
}
}
};
</script>