-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathImageDisplay.vue
110 lines (104 loc) · 2.17 KB
/
ImageDisplay.vue
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
<div class="display-panel">
<div class="left">
<img class="img" :src="list[activeIndex].image" alt="" />
</div>
<div class="right">
<div
class="r-list-item"
:class="{ active: index === activeIndex }"
v-for="(item, index) of list"
:key="index"
@mouseenter="changeActiveIndex(index)"
>
<img :src="item.icon" alt="" v-if="index !== activeIndex" />
<span class="sub-title-1">{{ item.title }}</span>
</div>
</div>
</div>
</template>
<script lang="ts">
interface ListItem {
icon: string
title: string
imageUrl: string
}
import { defineComponent, PropType, ref } from 'vue'
export default defineComponent({
props: {
list: {
type: Array as PropType<ListItem[]>,
required: true
}
},
setup() {
const activeIndex = ref(0)
const changeActiveIndex = (index: number) => {
activeIndex.value = index
}
return {
changeActiveIndex,
activeIndex
}
}
})
</script>
<style lang="less" scoped>
.display-panel {
display: flex;
flex-flow: row nowrap;
width: 100%;
justify-content: space-between;
align-items: flex-start;
.left {
flex: 1;
display: flex;
align-items: center;
justify-content: flex-start;
margin-right: 68px;
.img {
height: 100%;
max-width: 100%;
}
}
.right {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
align-items: center;
width: 384px;
.r-list-item {
cursor: pointer;
width: 180px;
height: 180px;
background: #f5f5f5;
display: flex;
flex-flow: column nowrap;
align-items: center;
justify-content: center;
margin-bottom: 24px;
img {
width: 47px;
height: 47px;
}
span.sub-title-1 {
font-size: 30px;
font-weight: 500;
color: #333333;
margin-top: 16px;
}
}
.r-list-item:nth-child(7),
.r-list-item:nth-child(8) {
margin-bottom: 0px;
}
.active {
transition: all 0.5s ease-in-out;
background: @primary;
span.sub-title-1 {
color: #fff;
}
}
}
}
</style>