A simple image / video lightbox component for Vue.js. Based on vue-image-lightbox.
Install the package:
npm install vue-it-bigger
yarn add vue-it-bigger
Then import it in your project at your entry point (main.js
normally)
import Vue from 'vue'
JavaScript
and use the lightbox:
import LightBox from 'vue-it-bigger'
export default {
components: {
LightBox,
},
}
JavaScript
<script src="path/to/vue.js"></script>
<script src="path/to/dist/vue-it-bigger.js"></script>
HTML
You can simply view App.vue to see how to use vue-it-bigger
Import CSS style
require('vue-it-bigger/dist/vue-it-bigger.min.css')
// Use only when you are using Webpack
JavaScript
How to use:
<LightBox :media="media"></LightBox>
HTML
[
{ // For image
thumb: 'http://example.com/thumb.jpg',
src: 'http://example.com/image.jpg',
caption: 'caption to display. receive <html> <b>tag</b>', // Optional
srcset: '...' // Optional for displaying responsive images
},
{ // For video
thumb: 'https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider2.jpg',
sources: [
{
src: 'https://www.w3schools.com/html/mov_bbb.mp4',
type: 'video/mp4'
}
],
type: "video",
caption: '<h4>Monsters Inc.</h4>',
width: 800, // Required
height: 600, // Required
autoplay: true, // Optional: Autoplay video when the lightbox opens
}
]
#lightbox #images #vue #vue.js #programming