更新记录

1.0.0(2025-07-03) 下载此版本

# uni-popup-indexed

## 简介

uni-popup-indexed 是一个功能强大的 uni-app 弹窗组件,支持索引功能、多种动画效果和位置配置,基于 Vue 3 Composition API 开发。

## 特性

-


平台兼容性

uni-app(4.05)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
- - - -
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 快应用-华为 快应用-联盟
- - - - - - - - - -

uni-app x(4.05)

Chrome Safari Android iOS 鸿蒙 微信小程序
- - - - - -

# popup-indexbar

## 简介

popup-indexbar 是一个功能强大的 uni-app 弹窗组件,支持索引功能、多种动画效果和位置配置,基于 Vue 3 Composition API 开发。

## 特性

- 🎯 支持多种弹窗位置:center、top、bottom、left、right

- 📇 **索引功能**:支持分组数据展示和快速索引跳转

- 📜 **滚动视图**:支持大量数据的高性能滚动展示

- 🎨 丰富的动画效果和交互体验

- 📱 完美支持各平台:APP、H5、小程序

- 🔧 灵活配置:背景色、圆角、层级等

- 🚀 基于 Vue 3 Composition API,性能更优

- 💡 轻量级,无依赖

## 安装

### 通过插件市场安装

在 uni-app 插件市场搜索 popup-indexbar,点击安装即可。

### 手动安装

1. 下载插件源码

2. 将 uni\_modules 目录复制到项目根目录

## 使用方法

### 基础用法


<template>

&nbsp; <view>

&nbsp;   <button @click="showPopup">打开基础弹窗</button>

&nbsp;   <popup-indexbar

&nbsp;     :show="isShow"

&nbsp;     title="基础弹窗"

&nbsp;     position="center"

&nbsp;     @update:show="isShow = $event"

&nbsp;     @close="closePopup"

&nbsp;   >

&nbsp;     <view class="popup-content">

&nbsp;       <text>这是基础弹窗内容</text>

&nbsp;       <button @click="closePopup">关闭</button>

&nbsp;     </view>

&nbsp;   </popup-indexbar>

&nbsp; </view>

</template>

<script setup>

import { ref } from 'vue'

const isShow = ref(false)

const showPopup = () => {

&nbsp; isShow.value = true

}

const closePopup = () => {

&nbsp; isShow.value = false

}

</script>

<style>

.popup-content {

&nbsp; padding: 30rpx;

&nbsp; text-align: center;

}

</style>

### 索引功能用法


<template>

&nbsp; <view>

&nbsp;   <button @click="showIndexedPopup">打开索引弹窗</button>

&nbsp;   <popup-indexbar

&nbsp;     :show="indexedShow"

&nbsp;     title="城市选择"

&nbsp;     position="bottom"

&nbsp;     :enableIndexbar="true"

&nbsp;     :indexedData="cityData"

&nbsp;     :scrollViewHeight="500"

&nbsp;     @update:show="indexedShow = $event"

&nbsp;     @item-click="onCitySelect"

&nbsp;   >

&nbsp;     <template #item="{ item, group }">

&nbsp;       <view class="city-item">

&nbsp;         <text class="city-name">{{ item.name }}</text>

&nbsp;         <text class="city-code">{{ item.code }}</text>

&nbsp;       </view>

&nbsp;     </template>

&nbsp;   </popup-indexbar>

&nbsp; </view>

</template>

<script setup>

import { ref } from 'vue'

const indexedShow = ref(false)

// 索引数据格式

const cityData = ref(\[

&nbsp; {

&nbsp;   key: 'A',

&nbsp;   title: 'A',

&nbsp;   items: \[

&nbsp;     { id: '1', name: '安庆', code: 'AQ' },

&nbsp;     { id: '2', name: '安阳', code: 'AY' }

&nbsp;   ]

&nbsp; },

&nbsp; {

&nbsp;   key: 'B',

&nbsp;   title: 'B',

&nbsp;   items: \[

&nbsp;     { id: '3', name: '北京', code: 'BJ' },

&nbsp;     { id: '4', name: '保定', code: 'BD' }

&nbsp;   ]

&nbsp; }

&nbsp; // ... 更多数据

])

const showIndexedPopup = () => {

&nbsp; indexedShow.value = true

}

const onCitySelect = (data) => {

&nbsp; console.log('选择城市:', data.item)

&nbsp; indexedShow.value = false

}

</script>

<style>

.city-item {

&nbsp; display: flex;

&nbsp; justify-content: space-between;

&nbsp; align-items: center;

}

.city-name {

&nbsp; font-size: 28rpx;

&nbsp; color: #333;

}

.city-code {

&nbsp; font-size: 24rpx;

&nbsp; color: #999;

}

</style>

### 高级用法


<template>

&nbsp; <view>

&nbsp;   <!-- 自定义插槽用法 -->

&nbsp;   <popup-indexbar

&nbsp;     :show="isShow"

&nbsp;     title="高级弹窗"

&nbsp;     position="bottom"

&nbsp;     :maskClosable="true"

&nbsp;     :showClose="true"

&nbsp;     :round="true"

&nbsp;     :zIndex="1000"

&nbsp;     @open="onOpen"

&nbsp;     @close="onClose"

&nbsp;     @opened="onOpened"

&nbsp;     @closed="onClosed"

&nbsp;   >

&nbsp;     <template #header>

&nbsp;       <view class="custom-header">

&nbsp;         <text class="title">自定义标题</text>

&nbsp;         <view class="actions">

&nbsp;           <button @click="handleConfirm">确定</button>

&nbsp;         </view>

&nbsp;       </view>

&nbsp;     </template>

&nbsp;     <view class="content">

&nbsp;       <text>自定义内容</text>

&nbsp;     </view>

&nbsp;     <template #footer>

&nbsp;       <view class="custom-footer">

&nbsp;         <button @click="closePopup">取消</button>

&nbsp;         <button @click="handleConfirm">确定</button>

&nbsp;       </view>

&nbsp;     </template>

&nbsp;   </popup-indexbar>

&nbsp; </view>

</template>

## Props

| 参数名 | 类型 | 默认值 | 说明 |

|--------|------|--------|------|

| show | Boolean | false | 是否显示弹窗 |

| title | String | '' | 弹窗标题 |

| position | String | 'center' | 弹窗位置:center/top/bottom/left/right |

| maskClosable | Boolean | true | 是否允许点击遮罩关闭 |

| showClose | Boolean | true | 是否显示关闭按钮 |

| zIndex | Number | 999 | 弹窗层级 |

| round | Boolean | true | 是否显示圆角 |

| overlay | Boolean | true | 是否显示遮罩 |

| **索引相关** |

| enableIndexbar | Boolean | false | 是否启用索引功能 |

| indexedData | Array | [] | 索引数据 |

| showIndexbar | Boolean | true | 是否显示索引条 |

| stickyOffsetTop | Number | 0 | 吸顶偏移量 |

| scrollViewHeight | Number | 400 | 滚动视图高度(px) |

## Events

| 事件名 | 说明 | 回调参数 |

|--------|------|----------|

| update:show | 弹窗显示状态变化 | Boolean |

| open | 弹窗开始打开时触发 | - |

| opened | 弹窗打开动画完成后触发 | - |

| close | 弹窗开始关闭时触发 | - |

| closed | 弹窗关闭动画完成后触发 | - |

| item-click | 点击索引项时触发 | { item, group } |

## Slots

| 插槽名 | 说明 | 参数 |

|--------|------|------|

| default | 默认内容 | - |

| header | 自定义头部 | - |

| footer | 自定义底部 | - |

| item | 自定义索引项内容 | { item, group } |

## Methods

| 方法名 | 说明 | 参数 |

|--------|------|------|

| open | 打开弹窗 | - |

| close | 关闭弹窗 | - |

| scrollToIndex | 滚动到指定索引 | index: Number |

| calculateGroupPositions | 重新计算分组位置 | - |

## 索引数据格式


const indexedData = \[

&nbsp; {

&nbsp;   key: 'A',        // 索引键,显示在索引条上

&nbsp;   title: 'A',      // 分组标题

&nbsp;   items: \[         // 分组项目

&nbsp;     {

&nbsp;       id: '1',           // 唯一标识

&nbsp;       name: '安庆',      // 显示名称

&nbsp;       code: 'AQ',        // 其他数据

&nbsp;       // ...更多自定义字段

&nbsp;     }

&nbsp;   ]

&nbsp; }

]

## 注意事项

1. **Vue 3 兼容性**:组件基于 Vue 3 Composition API 开发,需要 Vue 3 环境

2. **索引功能**:使用索引功能时,数据必须按照指定格式传入

3. **性能优化**:大量数据时建议设置合适的 scrollViewHeight

4. **平台差异**:在小程序中使用时,注意层级和滚动问题

5. **事件处理**:推荐使用 v-model 或 @update:show 处理显示状态

## 平台兼容性

| 平台 | 支持程度 | 注意事项 |

|------|----------|----------|

| APP | ✅ 完全支持 | - |

| H5 | ✅ 完全支持 | - |

| 微信小程序 | ✅ 完全支持 | 注意层级问题 |

| 支付宝小程序 | ✅ 完全支持 | - |

| 其他小程序 | ✅ 完全支持 | 部分功能可能有差异 |

## 更新日志

### 1.0.0 (2025-01-01)

- 🎉 初始版本发布

- ✨ 支持基础弹窗功能

- ✨ 支持索引功能和滚动视图

- ✨ 基于 Vue 3 Composition API

- ✨ 支持多种位置和动画效果

- ✨ 完整的插槽和事件支持

## 联系我们

如有问题或建议,请通过以下方式联系:

- GitHub Issues

- QQ:765637726

- 邮箱:765637726@qq.com

## 许可证

MIT License

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问