Yt-UI
首页
快速开始
组件文档
首页
快速开始
组件文档
  • 表单组件

    • 输入框 Input
    • 多行输入框 Textarea
    • 开关 Switch
    • 多选框组 CheckboxGroup
    • 单选框组 RadioGroup
    • 滑块 Slider
    • 选择器 Picker
    • 日历 Calendar
    • 表单 Form
  • 展示组件

    • 头像 Avatar
    • 徽标 Badge
    • 卡片 Card
    • 标签 Tag
    • 步骤条 Steps
    • 结果页 Result
    • 空状态 Empty
    • 虚拟列表 VirtualList
  • 交互组件

    • 按钮 Button
    • 悬浮按钮 FAB
    • 图标 Icon
    • 搜索 Search
    • 分段器 Segment
    • 轮播 Swiper
    • 指示点 Dots
  • 反馈组件

    • 加载 Loading
    • 弹窗 Popup
    • 遮罩层 Overlay
    • 通告栏 NoticeBar
  • 导航组件

    • 标签栏 Tabbar
    • 顶部标签栏 TopTabbar
    • 折叠面板 Collapse
    • 课程表 Schedule
  • 布局组件

    • 分割线 Divider
    • 链接 Line
    • 可移动视图 MovableView

yt-dots 指示点组件

属性

属性名类型默认值说明
totalnumber1指示点总数
activeIndexnumber0当前激活的指示点索引
themeThemeColor | 'none''none'主题颜色
sizenumber24指示点整体缩放比例
direction'horizontal' | 'vertical''horizontal'指示点排列方向

示例

基本指示点

<yt-dots :total="5" />

<yt-dots :total="3" :activeIndex="1" />

主题指示点

<yt-dots :total="4" theme="forest" />

<yt-dots :total="5" :activeIndex="2" theme="ocean" />

<yt-dots :total="6" :activeIndex="3" theme="magic" />

<yt-dots :total="4" :activeIndex="1" theme="blossom" />

<yt-dots :total="5" :activeIndex="4" theme="sunshine" />

<yt-dots :total="3" :activeIndex="0" theme="classic" />

<yt-dots :total="6" :activeIndex="2" theme="forest-sky" />

<yt-dots :total="5" :activeIndex="1" theme="ocean-sky" />

<yt-dots :total="4" :activeIndex="3" theme="magic-sky" />

<yt-dots :total="5" :activeIndex="0" theme="blossom-sky" />

<yt-dots :total="6" :activeIndex="5" theme="sunshine-sky" />

垂直排列

<yt-dots :total="3" direction="vertical" />

<yt-dots :total="5" :activeIndex="2" direction="vertical" theme="forest" />

缩放大小

<yt-dots :total="4" :size="16" />

<yt-dots :total="5" :activeIndex="3" :size="32" theme="ocean" />

<yt-dots :total="3" :size="20" direction="vertical" theme="magic" />

轮播指示器

<script setup>
  import { ref, onMounted } from 'vue'

  const activeIndex = ref(0)
  const totalSlides = 5

  onMounted(() => {
    setInterval(() => {
      activeIndex.value = (activeIndex.value + 1) % totalSlides
    }, 3000)
  })
</script>

<template>
  <div class="carousel-container">
    <div class="slide">幻灯片 {{ activeIndex + 1 }}</div>
    <yt-dots
      :total="totalSlides"
      :activeIndex="activeIndex"
      theme="forest-sky"
    />
  </div>
</template>

分页指示

<view class="pagination">
  <button @click="prevPage">上一页</button>
  <yt-dots 
    :total="totalPages" 
    :activeIndex="currentPage" 
    theme="sunshine"
  />
  <button @click="nextPage">下一页</button>
</view>

步骤指示器

<view class="step-indicator">
  <view class="step" :class="{ active: currentStep >= 0 }">步骤1</view>
  <yt-dots :total="1" :activeIndex="currentStep > 0 ? 0 : -1" theme="forest" />
  <view class="step" :class="{ active: currentStep >= 1 }">步骤2</view>
  <yt-dots :total="1" :activeIndex="currentStep > 1 ? 0 : -1" theme="forest" />
  <view class="step" :class="{ active: currentStep >= 2 }">步骤3</view>
</view>

超出边界效果

<!-- 当activeIndex大于总数时,最后一个点会有特殊效果 -->
<yt-dots :total="3" :activeIndex="5" theme="magic-sky" />

完整示例

<script setup>
  import { ref } from 'vue'

  const activeIndex = ref(0)
  const totalDots = 5
  const themes = ['forest', 'ocean', 'magic', 'blossom', 'sunshine']

  function nextDot() {
    activeIndex.value = (activeIndex.value + 1) % totalDots
  }
</script>

<template>
  <view class="demo-container">
    <h3>轮播演示</h3>
    <view class="carousel-wrapper">
      <view class="slide-content">当前幻灯片 {{ activeIndex + 1 }} / {{ totalDots }}</view>
      <yt-dots
        :total="totalDots"
        :activeIndex="activeIndex"
        :theme="themes[activeIndex]"
        :size="28"
      />
    </view>
    <view class="controls">
      <button @click="() => (activeIndex = Math.max(0, activeIndex - 1))">上一个</button>
      <button @click="nextDot">下一个</button>
    </view>
  </view>
</template>
最近更新:: 2026/3/9 19:16
Contributors: CHEEMS, 2126340634
Prev
轮播 Swiper