更新记录

0.0.11(2024-05-21)

修复readme文档;

0.0.10(2024-05-21)

修复readme文档;

0.0.9(2024-05-21)

修复readme文档;

查看更多

平台兼容性

uni-app

Vue2 Vue3
?
app-vue app-nvue app-android app-ios
? ? ? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?
微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序 钉钉小程序 快手小程序 飞书小程序 京东小程序
? ? ? ? ? ? ? ? ?
快应用-华为 快应用-联盟
? ?

uni-app x

app-android app-ios
? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?

bsyy-uni-component-ts

指南

快速开始

下载插件并导入 HBuilderX

引入样式

  • App.vue:
@import "@/uni_modules/bsyy-uni-components-ts/styles/style.scss";

注册组件

easycom 方式
  • 配置 package.json:
{
    "easycom": {
        "custom": {
            "^bsyy-([^-].*)": "bsyy-uni-components-ts/components/bsyy-$1/bsyy-$1.vue"
        }
    }
}
  • 使用 xxx.vue:

    <bsyy-dialog>Hello Dialog!</bsyy-dialog>

组件

Overview 总览

以下是 bsyy-uni-components-ts 提供的所有组件。

  • Dialog 弹出框
  • Picker 选择器
  • Popup 弹出层
  • ...正在开发中

点我查看效果

Dialog 弹出框

基本用法

<script lang="ts" setup>
    const show = ref(true);
</script>

<template>
    <button @click="show = true">打开 Dialog</button>
    <bsyy-dialog v-model:show="show">
        <view class="dialog">Hello Dialog!</view>
    </bsyy-dialog>
</template>

API

Attributes
属性名 说明 类型 默认
v-model:show 是否显示 Dialog boolean true
close-on-click-overlay 是否在点击遮罩层后关闭 Dialog boolean true
z-index 和原生的 CSS 的 z-index 相同,改变 z 轴的顺序 number 2000
Slots
插槽名 说明
- Dialog 的内容
Events
事件名 说明 类型
close Dialog 关闭的回调 () => void

Picker 选择器

基本用法

<script lang="ts" setup>
    const modelValue = ref([0]);
    const columns = reactive([
        [
            { label: "汽车", value: 1 },
            { label: "高铁", value: 2 },
            { label: "飞机", value: 3 },
        ],
    ]);
</script>

<template>
    <bsyy-picker v-model="modelValue" :columns="columns" />
</template>

多选用法

<script lang="ts" setup>
    const modelValue = ref([0, 1]);
    const columns = reactive([
        [
            { label: "汽车", value: 1 },
            { label: "高铁", value: 2 },
            { label: "飞机", value: 3 },
        ],
        [
            { label: "矿泉水", value: 1 },
            { label: "汽水", value: 2 },
            { label: "果汁", value: 3 },
        ],
    ]);
</script>

<template>
    <bsyy-picker v-model="modelValue" :columns="columns" />
</template>

级联用法

<script lang="ts" setup>
    const citys = [
        {
            label: "北京",
            code: "0",
            children: [
                {
                    label: "北京市",
                    code: "00",
                    children: [
                        { label: "东城区", code: "000" },
                        { label: "西城区", code: "001" },
                        { label: "崇文区", code: "002" },
                    ],
                },
            ],
        },
        {
            label: "浙江省",
            code: "1",
            children: [
                {
                    label: "杭州市",
                    code: "10",
                    children: [
                        { label: "上城区", code: "100" },
                        { label: "下城区", code: "101" },
                    ],
                },
                {
                    label: "宁波市",
                    code: "11",
                    children: [
                        { label: "海曙区", code: "110" },
                        { label: "江东区", code: "111" },
                    ],
                },
            ],
        },
    ];
const citys = [
    {
        label: "北京",
        code: "0",
        children: [
            {
                label: "北京市",
                code: "00",
                children: [
                    { label: "东城区", code: "000" },
                    { label: "西城区", code: "001" },
                    { label: "崇文区", code: "002" },
                ],
            },
        ],
    },
    {
        label: "浙江省",
        code: "1",
        children: [
            {
                label: "杭州市",
                code: "10",
                children: [
                    { label: "上城区", code: "100" },
                    { label: "下城区", code: "101" },
                ],
            },
            {
                label: "宁波市",
                code: "11",
                children: [
                    { label: "海曙区", code: "110" },
                    { label: "江东区", code: "111" },
                ],
            },
        ],
    },
];
    const modelValue = ref([0, 0, 0]);
    const columns: { label: string; value: string }[][] = reactive([[], [], []]);
    columns[0] = citys.map((v) => ({ label: v.label, value: v.code }));
    const change = (e: { selectedValues: string[]; selectedOptions: { label: string; value: string }[][]; selectedIndexes: number[]; columnIndex: number }) => {
        if (e.columnIndex == 0) {
            modelValue.value[1] = 0;
            modelValue.value[2] = 0;
        } else if (e.columnIndex == 1) {
            modelValue.value[2] = 0;
        }
        countColumns();
    };
    countColumns();
    function countColumns() {
        columns[1] = citys[modelValue.value[0]].children.map((v) => ({ label: v.label, value: v.code }));
        columns[2] = citys[modelValue.value[0]].children[modelValue.value[1]].children.map((v) => ({ label: v.label, value: v.code }));
    }
</script>

<template>
    <bsyy-picker v-model="modelValue" :columns="columns" @change="change($event)" />
</template>

API

Attributes
属性名 说明 类型 默认
model-value / v-model 当前选中项对应的下标 number[] []
columns 每一列显示的数据 { label: string; value: any }[][] []
Events
事件名 说明 类型
change 选中的选项改变时触发 ($event: { selectedValues: any[]; selectedOptions: { label: string; value: any }[]; selectedIndexes: number[]; columnIndex: number }) => void

Popup 弹出层

基本用法

<script lang="ts" setup>
    const show = ref(true);
</script>

<template>
    <button @click="show = true">打开 Popup</button>
    <bsyy-popup v-model:show="show">
        <view class="popup">Hello Popup!</view>
    </bsyy-popup>
</template>

API

Attributes
属性名 说明 类型 默认
v-model:show 是否显示  Popup boolean true
position 弹出位置 "left"| "right" | "top" | "bottom" "bottom"
close-on-click-overlay 是否在点击遮罩层后关闭  Popup boolean true
z-index 和原生的 CSS 的 z-index 相同,改变 z 轴的顺序 number 2000
Slots
插槽名 说明
- Popup 的内容
Events
事件名 说明 类型
close Popup 关闭的回调 () => void

更多

欢迎提出在留言区提出你需要的功能或 bug。

隐私、权限声明

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

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

插件不采集任何数据

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

许可协议

MIT协议

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