更新记录

1.0.0.1(2026-01-07) 下载此版本

master

1.0.0(2026-01-06) 下载此版本

master


平台兼容性

uni-app(4.13)

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

其他

多语言 暗黑模式 宽屏模式
× ×

安装

在市场导入xf-pk-single-select-modaluni_modules版本的即可,无需import

组件关联说明

代码演示

基本用法

  • 使用组件代码如下:

普通搜索单选

<template>
    <scroll-view class="xf-col-center" scroll-y>
        <h3>单选</h3>
        <view style="width: 100%;">
            <xf-pk-single-select-modal required pickerTitle="标题可搜索" :isPaging="false" :apiFn="getList" v-model="selectedF3" valueKey="id"
                labelKey="customerAddr" v-model:show="show" @confirm="confirm">
            </xf-pk-single-select-modal>

            //插槽用法
            <xf-pk-single-select-modal :isPaging="false" :apiFn="getList" v-model="selectedF3" valueKey="id"
                labelKey="customerAddr" v-model:show="show" @confirm="confirm">
                <template #content>
                    <xf-fm-select title="自定义插槽可搜" @click="show = true" v-model:value="selectedF3Text"
                        labelKey="customerAddr">
                    </xf-fm-select>
                </template>
            </xf-pk-single-select-modal>
        </view>
    </scroll-view>
</template>

可搜可输入

<template>
    <scroll-view class="xf-col-center" scroll-y>
        <h3>单选</h3>
        <view style="width: 100%;">
            <xf-pk-single-select-modal :isPaging="false" :apiFn="getList" v-model="selectedF3" valueKey="id"
                labelKey="customerAddr" v-model:show="show" @confirm="confirm">
                <template #content>
                    <xf-fm-select title="自定义插槽可搜" @click="show = true" v-model:value="selectedF3Text"
                        labelKey="customerAddr">
                    </xf-fm-select>
                </template>
            </xf-pk-single-select-modal>
        </view>
    </scroll-view>
</template>

只能手动录入

<template>
    <scroll-view class="xf-col-center" scroll-y>
        <h3>单选</h3>
        <view style="width: 100%;">
            <xf-pk-single-select-modal hasInput :isShowSearch="false" :apiFn="getList" v-model="selectedF3" valueKey="id"
                labelKey="customerAddr" v-model:show="show" @confirm="confirm">
                <template #content>
                    <xf-fm-select title="自定义插槽可搜" @click="show = true" v-model:value="selectedF3Text"
                        labelKey="customerAddr">
                    </xf-fm-select>
                </template>
            </xf-pk-single-select-modal>
        </view>
    </scroll-view>
</template>
<script setup lang="ts">
    import { computed, onMounted, ref, watch } from 'vue';

    const show = ref(false)
    const selectedF3 = ref()

    const selectedF3Text = ref()

    watch(() => selectedF3.value, (val) => {
        if (val) {
            selectedF3Text.value = list.value.find(e => selectedF3.value == e.id).customerAddr
        } else {
            selectedF3Text.value = null
        }
        console.log(selectedF3Text.value)
    })

    const getList = (search : string, page : number) => {
        createList()
        return new Promise((resolve) => {
            setTimeout(() => {
                let newList = list.value.filter(item => {
                    if (search) {
                        return item.customerAddr.includes(search)
                    }
                    else
                        return true
                })
                    .filter((item, index) => {
                        return index < page * 20 && index >= (page - 1) * 20
                    })
                let result = {
                    total: newList.length,
                    list: newList
                }
                resolve(result)
            }, 1000)
        })
    }

    const list = ref([])
    const createList = () => {
        if (list.value.length > 0)
            return
        for (let i = 0; i < 102; i++) {
            list.value.push({
                id: (i + 1) + "",
                customerAddr: "人力二部" + i
            })
        }
    }

    const confirm = (e) => {
        console.log(e)
        console.log(selectedF3.value)
    }
</script>

<style scoped lang="scss">
    view {
        margin-top: 10px;
    }
</style>

API

Props

属性名 说明 类型 默认值
v-model:modelValue 当前选中的value string -
v-model:show 自定义插槽时,是否打开弹窗 boolean false
pickerTitle 表单标题 string -
pickerBottomTip 表单标题下面提示语 object|string -
pickerTip 表单提示语 string -
searchPlaceholder 查询文案 string 请搜索
keyInPlaceholder 手动录入文案 string 请输入
hasInput 是否有手动录入 boolean false
title 弹出层标题 string 请选择
tip 弹出层副标题 string -
apiFn 请求数据回调方法 object -
valueKey 列表对象value值对应的key string value
labelKey 列表对象label值对应的key string label
isSearchFirst 是否需要先搜索 boolean false
isShowSearch 是否展示搜索条件 boolean true
canRefresh 是否可以刷新 boolean true
isPaging 是否分页 boolean true
pageSize 每页数据量 默认10 number -

事件 Emits

事件名 说明 返回值
confirm 点击确认按钮事件

插槽 slot

名称 说明 返回值
content 当不是表单组件时,用于自定义

隐私、权限声明

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

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

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

许可协议

MIT协议

暂无用户评论。