singleImage.vue 1 KB
<template>
  <div class="single-image">
     <LayoutLink :href="data.url" class="link">
         <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>