magnifier.vue 1.07 KB
<template>
  <div>
    <el-dialog 
      title="图片详情"
      :fullscreen=true
      :visible.sync="dialogVisible"
      :before-close="handleClose">
    <div class="img-box" :style="'height:'+ height + 'px'">
      <img :src="picsrc" alt="">
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="handleClose">确 定</el-button>
    </span>
  </el-dialog>

  </div>
</template>

<script>
import {mapState} from 'vuex'
export default {
  data() {
    return {
      dialogVisible:false,
      height:800,
      picsrc:'',
    }
  },
  methods:{
    handleClose(){
      this.$store.commit('setImgsrc','');
      this.dialogVisible = false;
    }
  },
  computed:{
    ...mapState(['imgsrc'])
  },
  watch:{
    imgsrc(val){
      if(val != ''){
        this.picsrc = val;
        this.dialogVisible = true;
      }
    }
  }
}
</script>
<style lang="stylus" scoped>
.img-box{
  height 100%
  overflow hidden
  text-align center
  img {
    max-width 100%
    max-height 100%
  }
}
</style>