Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions examples/uni/src/pages-basic/image/base.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<view class="p-4 w-full">
<view class="space-y-4">
<!-- 基础用法 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
基础用法
</text>
<SkImage
src="https://picsum.photos/200/200"
width="200rpx"
height="200rpx"
/>
</view>

<!-- 指定尺寸 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
指定尺寸
</text>
<view class="flex gap-4">
<SkImage
src="https://picsum.photos/100/100"
width="100rpx"
height="100rpx"
/>
<SkImage
src="https://picsum.photos/150/150"
width="150rpx"
height="150rpx"
/>
<SkImage
src="https://picsum.photos/200/200"
width="200rpx"
height="200rpx"
/>
</view>
</view>

<!-- 全宽图片 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
全宽图片
</text>
<SkImage
src="https://picsum.photos/800/400"
width="100%"
height="400rpx"
/>
</view>
</view>
</view>
</template>
119 changes: 119 additions & 0 deletions examples/uni/src/pages-basic/image/error.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<template>
<view class="p-4 w-full">
<view class="space-y-4">
<!-- 默认错误提示 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
默认错误提示
</text>
<text class="text-caption text-neutral-600">
图片加载失败时显示默认错误提示
</text>
<SkImage
src="https://invalid-url.com/image.jpg"
width="200rpx"
height="200rpx"
radius="medium"
/>
</view>

<!-- 自定义错误图 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
自定义错误图
</text>
<text class="text-caption text-neutral-600">
使用自定义图片作为错误状态
</text>
<SkImage
src="https://invalid-url.com/image.jpg"
width="200rpx"
height="200rpx"
radius="medium"
error-image="https://via.placeholder.com/200x200/ffebee/c62828?text=Error"
/>
</view>

<!-- 自定义错误插槽 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
自定义错误插槽
</text>
<text class="text-caption text-neutral-600">
使用插槽自定义错误状态显示
</text>
<SkImage
src="https://invalid-url.com/image.jpg"
width="200rpx"
height="200rpx"
radius="medium"
>
<template #error>
<view class="w-full h-full flex-center flex-col gap-2 bg-danger/10">
<text class="text-danger text-2xl">
</text>
<text class="text-caption text-danger">
加载失败
</text>
</view>
</template>
</SkImage>
</view>

<!-- 隐藏错误提示 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
隐藏错误提示
</text>
<text class="text-caption text-neutral-600">
设置 isShowError 为 false 隐藏错误提示
</text>
<SkImage
src="https://invalid-url.com/image.jpg"
width="200rpx"
height="200rpx"
radius="medium"
:is-show-error="false"
/>
</view>

<!-- 错误图片列表 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
错误图片列表
</text>
<text class="text-caption text-neutral-600">
批量显示带错误处理的图片
</text>
<view class="grid grid-cols-3 gap-4">
<SkImage
v-for="i in 6"
:key="i"
:src="`https://invalid-url.com/image${i}.jpg`"
width="100%"
height="150rpx"
radius="small"
error-image="https://via.placeholder.com/150x150/f5f5f5/999999?text=Error"
/>
</view>
</view>

<!-- 空 src -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
空 src
</text>
<text class="text-caption text-neutral-600">
未提供图片地址时的错误状态
</text>
<SkImage
src=""
width="200rpx"
height="200rpx"
radius="medium"
/>
</view>
</view>
</view>
</template>
46 changes: 46 additions & 0 deletions examples/uni/src/pages-basic/image/lazy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<view class="p-4 w-full">
<view class="space-y-4">
<!-- 说明 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
懒加载示例
</text>
<text class="text-caption text-neutral-600">
滚动页面查看图片懒加载效果,图片进入可视区域时才会加载
</text>
</view>

<!-- 普通加载 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
普通加载
</text>
<SkImage
src="https://picsum.photos/400/300?random=1"
width="100%"
height="300rpx"
radius="medium"
/>
</view>

<!-- 懒加载图片列表 -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
懒加载图片列表
</text>
<view class="space-y-4">
<SkImage
v-for="i in 10"
:key="i"
:src="`https://picsum.photos/400/300?random=${i + 1}`"
width="100%"
height="300rpx"
radius="medium"
:is-lazy="true"
/>
</view>
</view>
</view>
</view>
</template>
107 changes: 107 additions & 0 deletions examples/uni/src/pages-basic/image/mode.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<template>
<view class="p-4 w-full">
<view class="space-y-4">
<!-- scaleToFill -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
scaleToFill - 不保持纵横比缩放
</text>
<SkImage
src="https://picsum.photos/400/200"
mode="scaleToFill"
width="200rpx"
height="200rpx"
/>
</view>

<!-- aspectFit -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
aspectFit - 保持纵横比,长边完整显示
</text>
<SkImage
src="https://picsum.photos/400/200"
mode="aspectFit"
width="200rpx"
height="200rpx"
/>
</view>

<!-- aspectFill -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
aspectFill - 保持纵横比,短边完整显示
</text>
<SkImage
src="https://picsum.photos/400/200"
mode="aspectFill"
width="200rpx"
height="200rpx"
/>
</view>

<!-- widthFix -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
widthFix - 宽度不变,高度自动变化
</text>
<SkImage
src="https://picsum.photos/400/200"
mode="widthFix"
width="200rpx"
/>
</view>

<!-- heightFix -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
heightFix - 高度不变,宽度自动变化
</text>
<SkImage
src="https://picsum.photos/400/200"
mode="heightFix"
height="200rpx"
/>
</view>

<!-- top -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
top - 不缩放,显示顶部区域
</text>
<SkImage
src="https://picsum.photos/400/400"
mode="top"
width="200rpx"
height="200rpx"
/>
</view>

<!-- center -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
center - 不缩放,显示中间区域
</text>
<SkImage
src="https://picsum.photos/400/400"
mode="center"
width="200rpx"
height="200rpx"
/>
</view>

<!-- bottom -->
<view class="space-y-2">
<text class="text-body-medium font-medium">
bottom - 不缩放,显示底部区域
</text>
<SkImage
src="https://picsum.photos/400/400"
mode="bottom"
width="200rpx"
height="200rpx"
/>
</view>
</view>
</view>
</template>
Loading