singleImage.vue
1.02 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
<template>
<div class="single-image">
<LayoutLink :href="data.url" class="link" v-if="data.src">
<img :src="data.src" :alt="data.title" class="img" :style="style">
</LayoutLink>
</div>
</template>
<script>
import {mapState, mapMutations} from 'vuex';
export default {
name: 'single-image',
props: {
data: {
type: Object,
default: {}
}
},
data() {
return {
};
},
computed: {
...mapState({
style:(state) => {
return { height:`${state.yoho.window.clientWidth*240/1000}px` }
}
})
},
created() {
let clientWidth = document.body.clientWidth
this.SET_WINDOW_SIZE({clientWidth})
},
methods: {
...mapMutations(['SET_WINDOW_SIZE']),
}
};
</script>
<style lang="scss" scoped>
.single-image {
width: 100%;
margin: 20px 0;
overflow: hidden;
display: flex;
flex-direction: row;
align-items: center;
.link {
flex: 1;
}
.img {
display: block;
margin: 0 auto;
}
}
</style>