Skip to content

Before After Slider ​

Vue 已实现 · 还原验收 0/1 · 上游演示 · 固定版本源码

预览 ​

Lake house at dawn, color graded
Lake house at dawn, unedited

用法 ​

vue
<script setup lang="ts">
import { BeforeAfterSlider } from 'beui-vue'

const photo = 'https://images.unsplash.com/photo-1470770841072-f978cf4d019e?auto=format&fit=crop&w=1200&q=80'
</script>

<template>
  <div class="comparison-demo">
    <BeforeAfterSlider data-testid="comparison-frame">
      <template #before><img class="photo unedited" :src="photo" width="1200" height="800" alt="Lake house at dawn, unedited" draggable="false" /></template>
      <template #after><img class="photo" :src="photo" width="1200" height="800" alt="Lake house at dawn, color graded" draggable="false" /></template>
    </BeforeAfterSlider>
  </div>
</template>

<style scoped>
.comparison-demo { box-sizing: border-box; width: 100%; max-width: 36rem; min-width: 0; margin: 0 auto; padding: 1.5rem 1rem; }
.photo { display: block; width: 100%; height: 100%; object-fit: cover; } .unedited { filter: brightness(.9) contrast(.75) grayscale(1); }
</style>

API ​

#before、#after 提供比较内容。v-model 同步分隔位置,defaultValue 设置初始位置,disabled 禁用交互,labels 定制文本。

还原验收 ​

基于 beUI 的独立 Vue 移植,依 MIT 许可证分发。