Skip to content

Preview 预览

代码演示

基础用法

vue
<template>
    <a-button
        type="primary"
        @click="handlePreview">
        预览
    </a-button>
</template>

<script setup>
import { Preview } from '@/components'

function handlePreview() {
    Preview({
        urls: ['http://cdn.xuanyunet.com/test/1.jpeg'],
    })
}
</script>

<style lang="less" scoped></style>

多媒体

vue
<template>
    <a-button
        type="primary"
        @click="handlePreview">
        预览
    </a-button>
</template>

<script setup>
import { Preview } from '@/components'

function handlePreview() {
    Preview({
        current: 1,
        urls: [
            'http://cdn.xuanyunet.com/test/1.jpeg',
            'http://cdn.xuanyunet.com/test/2.jpeg',
            'http://cdn.xuanyunet.com/test/3.jpeg',
            'http://cdn.xuanyunet.com/test/4.jpeg',
        ],
    })
}
</script>

<style lang="less" scoped></style>

多张图片预览

vue
<template>
    <a-button
        type="primary"
        @click="handlePreview">
        预览
    </a-button>
</template>

<script setup>
import { Preview } from '@/components'

function handlePreview() {
    Preview({
        urls: [
            'http://cdn.xuanyunet.com/test/1.jpeg',
            'http://cdn.xuanyunet.com/test/1.mp3',
            'http://cdn.xuanyunet.com/test/1.mp4',
        ],
    })
}
</script>

<style lang="less" scoped></style>

API

Props

名称说明类型默认值
urlsurl 数组,支持 image/* .mp3 .mp4array-
current预览起始位置索引number0

本文档内容版权为 XYAdmin 作者所有,保留所有权利。