# Image 画像
プレビュー可能な画像コンテナです。fit はネイティブの object-fit を透過し、preview でクリックプレビューを有効にし、previewSrcList で複数画像の閲覧をサポートします。
画像
<template>
<div class="demo-col">
<div class="demo-row" style="gap: 24px; flex-wrap: wrap; align-items: flex-start">
<div class="demo-col" style="gap: 8px">
<LhImage :src="src" alt="溪山行旅図" fit="cover" preview />
<span class="demo-note">cover + プレビュー可能</span>
</div>
<div class="demo-col" style="gap: 8px">
<LhImage :src="src" alt="contain モード" fit="contain" />
<span class="demo-note">contain</span>
</div>
<div class="demo-col" style="gap: 8px">
<LhImage :src="src" alt="遅延読み込み" fit="fill" lazy />
<span class="demo-note">fill + lazy</span>
</div>
</div>
<p class="demo-note">previewSrcList の複数画像プレビュー(最初の画像をクリックして順に閲覧)</p>
<LhImage :src="src" alt="複数画像プレビューの入口" fit="cover" preview :preview-src-list="gallery" />
</div>
</template>
<script>
export default {
data: () => ({
src: 'data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20width=%27240%27%20height=%27160%27%3E%3Crect%20width=%27240%27%20height=%27160%27%20fill=%27%23e8e2d5%27/%3E%3Cpath%20d=%27M0%20115%20Q60%2080%20120%20115%20T240%20115%20V160%20H0%20Z%27%20fill=%27%23c9c2b2%27/%3E%3Ctext%20x=%2750%%27%20y=%2767%27%20font-size=%2718%27%20fill=%27%232b4c7c%27%20text-anchor=%27middle%27%20font-family=%27serif%27%3E%E6%BA%AA%E5%B1%B1%E8%A1%8C%E6%97%85%E5%9B%BE%3C/text%3E%3C/svg%3E',
gallery: [
'data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20width=%27640%27%20height=%27420%27%3E%3Crect%20width=%27640%27%20height=%27420%27%20fill=%27%23e8e2d5%27/%3E%3Cpath%20d=%27M0%20302%20Q160%20210%20320%20302%20T640%20302%20V420%20H0%20Z%27%20fill=%27%23c9c2b2%27/%3E%3Ctext%20x=%2750%%27%20y=%27176%27%20font-size=%2740%27%20fill=%27%232b4c7c%27%20text-anchor=%27middle%27%20font-family=%27serif%27%3E%E7%AC%AC%E4%B8%80%E5%B9%85%3C/text%3E%3C/svg%3E',
'data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20width=%27640%27%20height=%27420%27%3E%3Crect%20width=%27640%27%20height=%27420%27%20fill=%27%23e8e2d5%27/%3E%3Cpath%20d=%27M0%20302%20Q160%20210%20320%20302%20T640%20302%20V420%20H0%20Z%27%20fill=%27%23c9c2b2%27/%3E%3Ctext%20x=%2750%%27%20y=%27176%27%20font-size=%2740%27%20fill=%27%232b4c7c%27%20text-anchor=%27middle%27%20font-family=%27serif%27%3E%E7%AC%AC%E4%BA%8C%E5%B9%85%3C/text%3E%3C/svg%3E',
'data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20width=%27640%27%20height=%27420%27%3E%3Crect%20width=%27640%27%20height=%27420%27%20fill=%27%23e8e2d5%27/%3E%3Cpath%20d=%27M0%20302%20Q160%20210%20320%20302%20T640%20302%20V420%20H0%20Z%27%20fill=%27%23c9c2b2%27/%3E%3Ctext%20x=%2750%%27%20y=%27176%27%20font-size=%2740%27%20fill=%27%232b4c7c%27%20text-anchor=%27middle%27%20font-family=%27serif%27%3E%E7%AC%AC%E4%B8%89%E5%B9%85%3C/text%3E%3C/svg%3E',
],
}),
}
</script>
# Props
| プロパティ | 説明 | 型 | デフォルト値 |
|---|---|---|---|
| src | 画像のアドレス | string | — |
| alt | 代替テキスト(a11y の強い制約。TS 層で必須) | string | — |
| fit | 切り抜きモード(ネイティブ object-fit) | 'fill' \| 'contain' \| 'cover' \| 'none' \| 'scale-down' | 'cover' |
| preview | クリックしてプレビュー可能にするかどうか | boolean | false |
| previewSrcList | プレビュー画像のリスト(渡さない場合は [src] に縮退) | string[] | — |
| lazy | ネイティブの遅延読み込み(loading="lazy") | boolean | false |
| sx | sx によるレイアウト省略記法 | — | — |
# ImageViewer Props
個別にエクスポートされるビューアーです:images(プレビュー画像リスト)、initialIndex(初期インデックス、デフォルトは 0)。
ヒント
LhImage の preview には viewer が内蔵されており、ほとんどの場面で LhImageViewer を直接使う必要はありません。
Copyright © 2024-2026 FengMo WenXue