# hy-vue-photoswipe

> 基于photoswipe的vue预览组件

Latest version **0.0.1** (published 2019-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install hy-vue-photoswipe
pnpm add hy-vue-photoswipe
yarn add hy-vue-photoswipe
bun add hy-vue-photoswipe
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-09-17 |
| First published | 2019-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 140.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | zhhshen |
| Maintainers | piappcn |
| Keywords | photoswipe, vue, webpack |

## Links

- npm: https://www.npmjs.com/package/hy-vue-photoswipe
- Repository: https://github.com/zhhshen/vue-photo-swipe
- Homepage: https://github.com/zhhshen/vue-photo-swipe#readme
- Issues: https://github.com/zhhshen/vue-photo-swipe/issues
- npm.io page: https://npm.io/package/hy-vue-photoswipe

## Dependencies (1)

- [photoswipe](https://npm.io/package/photoswipe.md) ^4.1.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2019-09-17

## README

# hy-vue-photoswipe

基于photoswipe实现的vue图片预览组件

出自
https://www.npmjs.com/package/vue-image-swipe
### 安装

1 第一步
```
npm install hy-vue-photoswipe -D
```
2 第二步

vue 入口文件引入

``` javascript
import Vue from 'vue'
import VueImageSwipe from 'hy-vue-photoswipe'
import 'hy-vue-photoswipe/dist/vue-image-swipe.css'
Vue.use(VueImageSwipe)
```

### 使用

```
<template>
<div>
  hello world
  <div>
    <ul>
      <li
        :key="index"
        @click="preview(index)"
        v-for="(l, index) in images">
         <img :src="l" alt="">
      </li>
    </ul>
  </div>
</div>
</template>
<script>
export default {
  name: 'app',
  data() {
    return {
      images: [
        'http://oayhezji6.bkt.clouddn.com/preview1.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview2.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview3.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview9.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview10.jpg',
        'http://oayhezji6.bkt.clouddn.com/preview6.jpg'
      ]
    }
  },
  created() {
  },
  methods: {
    preview(index) {
      this.$imagePreview({
        images: this.images,
        index: index,
      })
    }
  }
}
</script>
```
### methods

只暴露了一个方法**this.$imagePreview**，并绑定到vue的原型上
使用
```
this.$imagePreview(options = {})
```
options有三个参数

参数 | 默认值 | 说明
--- | ---| ---
images | 空数组 | 图片的url数组
index | 0 | 预览图片的索引值, 默认是0
defaultOpt | {} | 配置项

defaultOpt 的配置项请参考[photoswipe配置项](http://photoswipe.com/documentation/options.html)，
**注意：不能保证所有配置项都是可用的**

列举一些常用的配置
```
defaultOpt: {
  fullscreenEl: true,
  shareEl: false,
  arrowEl: true,
  preloaderEl: true,
  loop: false,
  bgOpacity: 0.85,
  showHideOpacity: true,
  errorMsg: '<div class="pswp__error-msg">图片加载失败</div>',
}
```
### demo

[demo](https://zhhshen.github.io/vue-image-swipe/example/index.html)
###  LICENSE

MIT

---
_Source: https://npm.io/package/hy-vue-photoswipe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
