card.vue
1.44 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<template>
<div :style="{ 'margin-top': +marginTop + 'px' }" class="box">
<div v-if="title" class="header" :style="{ cursor: openBtn ? 'pointer' : 'unset' }" @click.stop="showBody()">
<i v-if="openBtn" class="el-icon-caret-right" :class="{ trans: open }"></i>
{{ title }}
<div style="float:right">
<slot name="right"></slot>
</div>
</div>
<div v-if="!openBtn || open" class="main-wrap">
<slot></slot>
</div>
</div>
</template>
<script type="text/ecmascript-6">
export default {
name: 'card',
data() {
return {
open: false
}
},
props: {
title: {
type: String,
default: ''
},
openBtn: {
type: Boolean,
default: false
},
marginTop:{
tyep: Number|String,
default: 16
}
},
mounted() {},
methods:{
showBody(){
if(!this.openBtn) return
this.open = !this.open
}
}
}
</script>
<style lang="scss" scoped>
.box {
background-color: #fff;
.header {
height: 58px;
background-color: #fff;
line-height: 58px;
padding: 0 20px;
box-sizing: border-box;
font-family: inherit;
font-size: 16px;
color: #333333;
// font-weight: 600;
}
.main-wrap {
border-top: 1px solid #e5e5e5;
padding: 20px;
height: 100%;
position: relative;
}
}
.header .trans {
transform: rotate(90deg);
}
.header .el-icon-caret-right {
transition: transform 0.3s ease 0s;
}
</style>