Vue实现图片的放大缩小

Vue实现图片的放大缩小

 <style>代码

	.mengban{
		position: fixed;
		left: 0;
		top: 0;
		z-index: 9999;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0, 0.5);
		overflow: scroll;
			img{
				position: absolute;
				top: 20%;
				left: 50%;
				transform:translate(-50%,-12%);
                /*transform: scale(1);*/
                max-width: 800px;
			}
	}
    .imgButton{
        width: 40px;
        height: 40px;
		position: fixed;
        z-index:88;
        top: 80%;
		padding: 0;
	}

 <template>代码 

i-button使用的是iview的

<div>
	<img :src="mengbanSrc" :style="{maxWidth:imgW+'px'}"   ref="bigPic">
	<i-button shape="circle" class="imgButton" style="right: 150px;background-color:red;border:0;color:white;" @click="closeBigMeg"><h1>×</h1></i-button>
	<i-button  shape="circle" class="imgButton" style="right: 100px;border:0;" @click="imgW=imgW+100"><h1>+</h1></i-button>
	<i-button shape="circle" class="imgButton" style="right: 50px;border:0;border-radius: 50%" @click="imgW-100>0?imgW=imgW-100:100"><h1>-</h1></i-button>
</div>

<script>代码

data() {
    return {
        imgW:800
    }
},
methods: {
    closeBigMeg(){
	    this.isShowMb = false;
	    this.imgW = 800;
    }
}

效果如下:

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值