1.0.24 • Published 4 years ago

v-picview v1.0.24

Weekly downloads
18
License
MIT
Repository
github
Last release
4 years ago

v-picview GitHub package.json version Build Status vue

v-picview is a component of picture viewer.

Demo

How to use

npm i v-picview -S
import Vue from 'vue'
import 'v-picview/lib/v-picview.css'
import vPicview from 'v-picview'
import { vImage } from 'v-picview'
Vue.component(vImage)
Vue.use(vPicview,{
    escClose:true,
    arrowShortcuts:true,
    zoom:true,
    footer:true,
    animation:'fadein',
    popperClass:'my-picview-box',
    onDownload(item:any){
        console.log(item)
    },
    onNext(index:number, item:object, oldItem:object){
        console.log('下一页',index,item,oldItem)
    },
    onPrev(index:number, item:object, oldItem:object){
        console.log('上一页',index,item,oldItem)
    },
    onChange(index:number, item:object, oldItem:object){
        console.log('页数改变',index,item,oldItem)
    },
    onImgLoaded(e:any){
        console.log('图片加载完成',e)
    },
    onZoomIned(e:any){
        console.log('图片放大',e)
    },
    onZoomOuted(e:any){
        console.log('图片缩小',e)
    },
    onDragStart(e:any){
        console.log('拖拽开始',e)
    },
    onDragMove(e:any){
        console.log('拖拽中',e)
    },
    onDragEnd(e:any){
        console.log('拖拽结束',e)
    }
})
<!-- Component mode initialization -->
<v-image 
    class="inline-block" 
    describe="group set-1" 
    :src="require('@/assets/pic1.png')" 
    mode="aspectFit" 
    group="set-1" 
/>

<!-- Directive mode initialization -->
<img 
    src="~@/assets/logo.png" 
    v-picview="{group:'set-2',describe:'group set-2'}" 
/>

API

v-picview directive attributes:

Attr. NameDescriptionRequiredDefault Value
describe图片的描述,如果打开了vPicview的footer会显示在底部N
group图片的分组,如果是同一分组的图片,在图片查看器里面可以进行左右切换查看N-

vImage component attributes:

Attr. NameDescriptionRequiredDefault Value
width图片的宽度N350px
height图片的高度N350px
src图片的地址路径Y
describe图片的描述,如果打开了vPicview的footer会显示在底部N
viewSrc图片查看器的图片地址路径,如果不填写,则默认取srcN
group图片的分组,如果是同一分组的图片,在图片查看器里面可以进行左右切换查看N-
noView点击是否打开图片查看器,默认是点击后打开查看器Nfalse
modescaleToFill:不保持纵横比缩放图片,使图片的宽高完全拉伸至填满 image 元素。 aspectFit:缩放模式,保持纵横比缩放图片,使图片的长边能完全显示出来。也就是说,可以完整地将图片显示出来。 aspectFill:缩放模式,保持纵横比缩放图片,只保证图片的短边能完全显示出来。也就是说,图片通常只在水平或垂直方向是完整的,另一个方向将会发生截取。 widthFix:缩放模式,宽度不变,高度自动变化,保持原图宽高比不变。NscaleToFill

vPicview component attributes:

Attr. NameDescriptionRequiredDefault Value
arrowShortcuts是否启用左右箭头键切换图片页数Ntrue
zoom是否需要放大功能Ntrue
footer是否启用底部栏显示描述Ntrue
animation打开的动画:fadein,flyinNfadein
popperClass图片查看器的classN-
onDownload点击下载图标的回调函数N-
onNext触发下一页图片时的回调函数N-
onPrev触发上一页图片时的回调函数N-
onChange页数改变时的回调函数N-
onImgLoaded图片查看器在图片加载完成后的回调函数N-
onZoomIned图片放大时的回调函数N-
onZoomOuted图片缩小时的回调函数N-
onDragStart图片放大后拖动开始时的回调函数N-
onDragMove图片放大后拖动进行中的回调函数N-
onDragEnd图片放大后拖动结束时的回调函数N-

vPicview vm instance methods:

window.$picview可直接获取vPicview的实例

  • download() 下载查看器当前显示的图片
  • close() 关闭查看器
  • next() 下一页图片
  • prev() 上一页图片
1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago