vue 图片放大左右切换
来源:互联网 发布:网络使人亲切辩论会 编辑:程序博客网 时间:2024/06/05 06:03
html部分
<div id="app"> <div class="imgList"> <img :src="value" v-for="(value,index) in imgList" :key="value" @click="bigImg(index)"> </div> <div class="imgMask" v-if="showBigImg" @click.stop="showBigImg=!showBigImg"> <img class="prev" @click.stop="prev" src="http://cdn.attach.qdfuns.com/notes/pics/201708/28/152301mz6lgplg15rnnrl8.png"> <div class="showImg" > <img class="bigImg" :src="imgList[num]"> </div> <img class="next" @click.stop="next" src="http://cdn.attach.qdfuns.com/notes/pics/201708/28/152246ozacp0x2pxcecme2.png"> </div> </div>
css 部分
html,body,#app { height: 100%; width:100%; } *{ margin: 0; padding:0; box-sizing:border-box; } .imgList{ margin: 0 auto; width:900px; display: flex; flex-direction:row; flex-wrap:wrap; } .imgList img{ width:300px; } .imgMask{ position: absolute; height: 100%; width:100%; top:0; left:0; z-index: 100; background:rgba(0,0,0,.6); } .showImg{ height:550px; width:800px; position: absolute; left:50%; top:50%; transform:translate(-50%,-50%); border:10px solid #fff; } .bigImg{ width:100%; height:100%; } .prev{ position: absolute; top:50%; left:10px; width:40px; transform:translate(10px,-50%); } .next{ width:40px; transform:translate(10px,-50%); position: absolute; top:50%; right:20px; }
js部分
var app = new Vue({ el:"#app", data(){ return{ showBigImg:false, num:0, imgList:[ "http://cdn.attach.qdfuns.com/notes/pics/201708/28/152247enooreornrre1zca.jpg", "http://cdn.attach.qdfuns.com/notes/pics/201708/28/152606vaqgcsqzyhw9dd0q.jpg", "http://cdn.attach.qdfuns.com/notes/pics/201708/28/152427alkrlnhtkkghjjeu.jpg", "http://cdn.attach.qdfuns.com/notes/pics/201708/28/152247c00jnfwzfjqakjrj.jpg", "http://cdn.attach.qdfuns.com/notes/pics/201708/28/152247nm4jbbkbbklg4blp.jpg", "http://cdn.attach.qdfuns.com/notes/pics/201708/28/152247etznl2kk9nnk1i2n.jpg" ] } }, methods:{ bigImg(index){ this.showBigImg = true; this.num = index; }, prev(){ if(this.num==0){ this.num =6 } this.num--; console.log(this.num) }, next(){ if(this.num==5){ this.num=-1; } this.num++; } } })
阅读全文
1 0
- vue 图片放大左右切换
- 图片点击放大左右切换
- iPhone相册,(UIScrollView,UIPageControl的综合应用)捏合放大缩小, 左右滑动切换图片
- 左右图片切换
- 图片左右切换
- 左右滑动切换图片
- 图片的左右切换
- vue 实现点击图片放大
- onmouseover onmouseout 图片切换 放大
- 一行代码搞定:下拉放大图片, 导航栏颜色渐变, 添加子控制器, 左右滑动同时切换按钮
- js左右箭头图片切换
- 图片展示(手动左右切换)
- Android ImageSwitcher左右切换图片
- 带左右箭头图片切换
- 左右滑动浏览图片,选中图片放大,浮在左右图片之上,图片的放大缩小拖动,多指触控
- UIScrollView 放大缩小及同时切换图片
- jquery实现图片缩小放大的切换
- ViewFilpper、Gesture 实现图片左右滑动切换
- 面向对象(三)——友元函数和友元类
- js之prototype用法(给对象添加通用属性/方法)
- 堆和栈的区别
- 企业做营销型网站的目的
- 拼凑钱币 --漫漫算法路 刷题篇
- vue 图片放大左右切换
- spark读取gz文件与parquet文件
- EasyNVR H5无插件摄像机直播解决方案前端解析之:如何在播放界面添加实时云台控制界面
- 棋盘的表格布局
- spring整合hibernate,实体类由xml转向注解
- 面试准备1
- table表格
- python的学习资料
- Spring mvc中@RequestMapping 6个基本用法小结