vue 移动端图片预览的方法使用总结

方法一:使用插件vue-image-swipe预览,使用方法如下:

首先npm i 安装 vue-image-swipe,然后在入口文件use

import VueImageSwipe from 'vue-image-swipe'
import 'vue-image-swipe/dist/vue-image-swipe.css'
Vue.use (VueImageSwipe);
<div v-for="(item,index) in environmentalList" :key="index+'item'"
     @click="previeewEnv(index)"
>
    <img :src="item"/>
</div>
previeewEnv (index) {
    this.$imagePreview ({
        images: this.environmentalList,
        index: index,
        defaultOpt: {
            fullscreenEl: false,
            arrowEl: true,
            preloaderEl: true,
            bgOpacity: 0.85,
            showHideOpacity: true
        }
    })
},

效果如下:

方法二:使用v-viewer插件预览

import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
Vue.use (Viewer, {
    defaultOptions: {
        'navbar': true,
        'toolbar': false,
        'movable': false,
        'title': false,
        'zoomable': true,
        'scalable': true,
        'transition': true
    }
})
<viewer :images="imgList" class="imgWrapper">
    <div v-for="(item,index) in imgList" :key="index+'item'"
    >
        <img :src="item"/>
    </div>
</viewer>

预览效果如下:

具体配置文件可参考

 交流


1、QQ群:可添加qq群共同进阶学习: 进军全栈工程师疑难解  群:  856402057

2、公众号:公众号「进军全栈攻城狮」 ,对前端技术保持学习爱好者。我会经常分享自己所学所看的干货,在进阶的路上,共勉!

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值