@duoa/vue-img-preview

A simple & easy use image preview component.
762 2
Install
npm install @duoa/vue-img-preview
Latest Version:3.0.10
Vue:2
License:MIT
Last Updated:Apr 28, 2019
Links: GitHub  ·  npm
Maintainer: duoani

Vue Img Preview

A simple & easy use component for image preview.

Take a glance

Online Demo

Installation

npm i -S @duoa/vue-img-preview

Usage

Register the component

import Vue from 'vue'
import VueImgPreview from '@duoa/vue-img-preview'
// Because this components has its styles, you must also import the css file.
import '@duoa/vue-img-preview/dist/vue-img-preview.css'

// Register
Vue.use(VueImgPreview)

// You can also set the default z-index
Vue.use(VueImgPreview, {
  zIndex: 9999
})

You may now use the v-preview directive in your markup.

<template>
  <button v-preview="img">Preview</button>
</template>
<script>
export default {
  data () {
    return {
      img: 'http://your.img.url'
    }
  }
}
</script>

That's all you need to do!

If you want to specify the z-index property of the preview popup, use the v-preview:z-index directive.

If you want to display a title, use the v-preview:title directive.

<template>
  <button
    v-preview="img"
    v-preview:z-index="zIndex"
    v-preview:title="title">Preview</button>
</template>
<script>
export default {
  data () {
    return {
      img: 'http://your.img.url'
      zIndex: 999,
      title: 'A title'
    }
  }
}
</script>

API invocation

You can also use the this.$imgPreview(options) method instead of the v-preview directive.

<template>
  <button @click="handleClick">Preview</button>
</template>
<script>
export default {
  methods: {
    handleClick () {
      this.$imgPreview({
        img: 'http://your.img.url',
        title: 'Put a title here if needed',
        zIndex: 99
      })
    }
  }
}
</script>

Related Packages

vue-doc-preview

A vue document preview component

81,231 124
vue-preview

A Vue integration PhotoSwipe image preview plugin

20,276 637
vue-pdfjs

vue pdf preview

12,518 1
vue2-preview

A Vue2 image preview plugin

1,792 23
vue-preview-image

— A vue picture preview component.

1,572 1

Version History

Version Released Vue License
3.0.10 2.x MIT
3.0.9 2.x MIT
3.0.8 2.x MIT
3.0.7 2.x MIT
3.0.6 2.x MIT