Lightbox
Examples
<template>
<article>
<section>
<veui-check-box
v-model="wrap"
class="checkbox"
>
循环播放
</veui-check-box>
<veui-check-box
v-model="indicator"
class="checkbox"
true-value="number"
false-value="none"
>
头部页码
</veui-check-box>
</section>
<veui-button
ui="primary"
@click="open = true"
>
展现灯箱
</veui-button>
<veui-lightbox
:open.sync="open"
:datasource="items"
:wrap="wrap"
:indicator="indicator"
/>
</article>
</template>
<script>
import { Lightbox, Checkbox, Button } from 'veui'
export default {
components: {
'veui-lightbox': Lightbox,
'veui-check-box': Checkbox,
'veui-button': Button
},
data () {
return {
wrap: false,
indicator: 'number',
open: false
}
},
computed: {
items () {
return [
{
src:
'https://ecmb.bdimg.com/public01/one-design/2b77cc4a4c5c906993c0e512f3ddaf03.jpg',
alt: 'A cute kitty looking at you with its greenish eyes.',
desc: 'Cat'
},
{
src:
'https://ecmb.bdimg.com/public01/one-design/6fedc62b9221846ce5114c7447622e47.jpeg',
alt: 'A common kingfisher flying above river.',
desc: 'Kingfisher'
},
{
src: 'https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm',
alt: 'flower video',
desc: '花',
type: 'video'
},
{
src:
'https://ecmb.bdimg.com/public01/one-design/e1b6473c898d9e456452ee79d7533a86.jpeg',
alt: 'A white and gray dolphin in blue water.',
desc: 'Dolphin'
}
]
}
}
}
</script>
<style lang="less" scoped>
.checkbox {
margin-right: 15px;
}
section {
margin-bottom: 12px;
}
</style>
API
Props
Name | Type | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ui | string | - | Predefined style. Customizable when veui-theme-dls is not provided. | |||||||||||||||
open | boolean | false | Whether to show the dialog.
Whether to show the dialog. | |||||||||||||||
datasource | Array<Object> | [] | The data source of the lightbox, with the following properties:
| |||||||||||||||
index | number | 0 |
The current playing index. | |||||||||||||||
wrap | boolean | false | Whether to play in a loop. | |||||||||||||||
closable | boolean | true | Whether to show the close button. | |||||||||||||||
escapable | boolean | true | Whether to close the dialog by pressing esc. Only works when closable is true . | |||||||||||||||
outside-closable | boolean | true | Whether to close the dialog when clicking outside the content area. | |||||||||||||||
priority | number | - | The z-index of the dialog. Refer to the Overlay component's priority prop. | |||||||||||||||
before-close | function(string): boolean=|Promise<boolean> | - | Called before the dialog is closed, with a type of
| |||||||||||||||
overlay-class | string | Array | Object | - | The class name of the root element of the dialog. Refer to the Overlay component's overlay-class prop. | |||||||||||||||
indicator | string | 'number' | The display mode of the playback progress indicator.
| |||||||||||||||
options | Object | { video: { muted: true, autoplay: true, controls: true } } | Additional configuration. | |||||||||||||||
lazy | boolean= | { preload: number } | false | Specifies whether to lazy load the carousel resources.
|
Slots
Name | Description |
---|---|
item | Used to customize the media display area for each lightbox item. Default content: each image or video. The slot props is the content of each list item of the |
desc | Used to customize the description area for each lightbox item. Default content: each item's description text. The slot props is the content of each list item of the |
Events
Name | Description |
---|---|
close | Triggered when the action to close the lightbox is performed. |
Icons
Name | Description |
---|---|
close | Close. |
prev | Previous page. |
next | Next page. |