0.1.2 • Published 3 years ago

vue-easy-imagepreview v0.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

vue-easy-imagepreview

手机端图片预览 vue 组件

功能:

  • 图片方大缩小
  • 循环滑动

安装

npm install -S vue-easy-imagepreview

使用

函数形式

import ImagePreview from 'vue-easy-imagepreview'

//ImagePreview.show(options | [])

ImagePreview.show([
  'https://img01.yzcdn.cn/vant/apple-1.jpg',
  'https://img01.yzcdn.cn/vant/apple-2.jpg'
])
或者
ImagePreview.show({
  images: [
    'https://img01.yzcdn.cn/vant/apple-1.jpg',
    'https://img01.yzcdn.cn/vant/apple-2.jpg'
  ]
})

组件形式

//在vue组件中使用

import ImagePreview from 'vue-easy-imagepreview'

<image-preview :images="images"></image-preview>

Vue 插件形式

import ImagePreview from 'vue-easy-imagepreview'

Vue.use(ImagePreview)

//组件中使用
this.$preview(options | [])

Options

参数说明类型可选值默认值
images要预览的图片地址array--
close关闭时的回调function: ()=>{}----
change图片切换时的回调function: (index) => {}----
loop是否循环滑动booleantrue/falsetrue
showIndex是否显示指示器booleantrue/falsetrue
maxZoom最大放大倍数number--3
minZoom最小缩小倍数number--0.5
index从第几个开始显示number--1

slot

名称说明
placeholderLoading图片加载中时的显示视图
placeholderFail图片加载失败时的显示视图
index指示器视图

Event

名称说明回调参数
close关闭时的回调--
change图片切换时的回调index