VEUI

VEUI on GitHub
Play!中文

Lightbox

Examples

Edit this demo on GitHubEdit
<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

NameTypeDefaultDescription
uistring-Predefined style. Customizable when veui-theme-dls is not provided.
openbooleanfalseWhether to show the dialog.

.sync

Whether to show the dialog.

datasourceArray<Object>[]

The data source of the lightbox, with the following properties: { src, alt, type, desc }.

NameTypeDescription
srcstringThe media source URL.
typestringThe default type of the image. video indicates a video.
altstringThe fallback text of the image.
descstringThe description text of the item.
indexnumber0

.sync

The current playing index.

wrapbooleanfalseWhether to play in a loop.
closablebooleantrueWhether to show the close button.
escapablebooleantrueWhether to close the dialog by pressing esc. Only works when closable is true.
outside-closablebooleantrueWhether to close the dialog when clicking outside the content area.
prioritynumber-The z-index of the dialog. Refer to the Overlay component's priority prop.
before-closefunction(string): boolean=|Promise<boolean>-

Called before the dialog is closed, with a type of function(): boolean=|Promise<boolean>. The return value can be a boolean, or a Promise that resolves to a boolean, used to handle situations where the dialog closing state may need to be decided asynchronously. The dialog will only be closed when the return value or resolve value is not false.

<veui-lightbox :open.sync="dialogOpen" :before-close="submit">...</veui-lightbox>
overlay-classstring | Array | Object-The class name of the root element of the dialog. Refer to the Overlay component's overlay-class prop.
indicatorstring'number'

The display mode of the playback progress indicator.

ValueDescription
numberDisplay the text prompt of "current page number/total page numbers".
noneDo not show the indicator.
optionsObject{ video: { muted: true, autoplay: true, controls: true } }Additional configuration.
lazyboolean= | { preload: number }false

Specifies whether to lazy load the carousel resources.

NameDescription
falseDo not lazy load resources.
truePreload the resources before and after the currently displayed item by 1.
{ preload: number }Preload the specified number of resources before and after the currently displayed item.

Slots

NameDescription
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 datasource prop (custom properties can be included) plus index: number to indicate the order of the carousel item. The entire slot-scope binding value is {src, alt, type, desc, index, ...}.

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 datasource prop (custom properties can be included) plus index: number to indicate the order of the carousel item. The entire slot-scope binding value is {src, alt, type, desc, index, ...}.

Events

NameDescription
closeTriggered when the action to close the lightbox is performed.

Icons

NameDescription
closeClose.
prevPrevious page.
nextNext page.
Edit this page on GitHubEdit
© Baidu, Inc. 2024