组件
图片查看器 Image Viewer
ImageViewer:图片查看器。图片显示在变暗的页面上,下方有小型工具栏。使用者可直接缩放,范围为 0.5 到 3 倍;旋转每次 90°,Escape 和 scrim 都能关闭,模态行为由 dialog 状态机处理。`open` 可以由调用方管理;未定义时由查看器自行维护。
#基础用法
<script setup lang="ts">
import { Button, ImageViewer } from "@bysages/vue";
import { ref } from "vue";
const SAMPLE = "https://picsum.photos/seed/elements-viewer/1600/1000";
const open = ref(false);
</script>
<template>
<div class="w-full">
<Button @click="open = true">Open viewer</Button>
<ImageViewer v-model:open="open" :src="SAMPLE" alt="A photograph from the archive" />
</div>
</template>
<script setup lang="ts">
import { Button, ImageViewer } from "@bysages/vue";
import { ref } from "vue";
const SAMPLE = "https://picsum.photos/seed/elements-viewer/1600/1000";
const open = ref(false);
</script>
<template>
<div class="w-full">
<Button variant="outline" @click="open = true">Open (no zoom)</Button>
<ImageViewer
v-model:open="open"
:src="SAMPLE"
alt="A photograph from the archive"
:zoomable="false"
/>
</div>
</template>
#属性
#ImageViewer
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
src | String | — | |
alt | String | "" | — |
open | Boolean | undefined | — |
zoomable | Boolean | true | — |