更新记录

1.0.1(2025-05-23) 下载此版本

修复外部因素关闭弹窗不触发 close 事件的问题

1.0.0(2025-01-27) 下载此版本

发布初版


平台兼容性

uni-app

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

其他

多语言 暗黑模式 宽屏模式 蒸汽模式
× × √ ×

组件名: xt-popup

安装方式

本组件符合 easycom 规范,HBuilderX 3.1.0 起,只需将本组件导入项目,在页面 template 中即可直接使用,无需在页面中 import 和注册 components

基本用法

<template>
    <view class="xt">
        <button @click="showPop(0)">弹窗</button>
        <button @click="showPop(1)">打印</button>
        <xt-popup :show.sync='show' iconColor='#000' iconPosition='topCenter' @close="close" radius="10rpx" showClose
            mode='right'>
            <view style="padding: 50rpx;height: 100%;">
                XT-POPUP弹窗
            </view>
        </xt-popup>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                show: false
            }

        },
        methods: {
            close() {
                console.log('关闭');
            },
            showPop(e) {
                if (e == 0) {
                    this.show = true
                } else {
                    console.log(this.show)
                }
            }
        },
    }
</script>

<style lang="scss">
    .xt {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
</style>

备注

绑定show字段时,vue3版本,双向绑定方式为 v-model:show='show';

vue2版本,双向绑定方式为 :show.sync='show';

也可自行处理 不使用双向绑定;

xt-popup 属性和方法

属性名 类型 默认值 必填 描述
show Boolean false 是 显示弹窗(默认值为 false)。
mask Boolean true 否 显示遮罩层(默认值为 true)。
zIndex Number 9999 否 弹窗层级(默认值为 9999)。
opacity Number 0.7 否 遮罩层透明度(默认值为 0.7)。
zoom Boolean true 否 弹窗是否缩放(mode为center时有效 默认值为 true)。
duration Number 300 否 动画过渡时间(默认值为 300 毫秒)。
closeOnClickMask Boolean true 否 点击遮罩层是否关闭弹窗(默认值为 true)。
mode String center 否 弹窗位置(可选值:top、bottom、center、left、right,默认值为 center)。
bgColor String #fff 否 弹窗背景颜色(默认值为 #fff)。
radius String 0rpx 否 弹窗圆角(默认值为 0rpx)。
showClose String false 否 显示关闭按钮(默认值为 false)。
iconColor String #909399 否 关闭按钮颜色(默认值为 #909399)。
iconPosition String topRight 否 关闭按钮位置(可选值:topRight、topLeft、bottomRight、bottomLeft、topCenter、bottomCenter、leftCenter、rightCenter,默认值为 topRight)。
safeAreaTop Boolean true 否 是否开启顶部安全区(状态栏高度,默认值为 true)。
safeAreaBottom Boolean true 否 是否开启底部安全区(默认值为 true)。
close (事件) Function - 否 关闭弹窗时触发的事件。

说明

  1. 适配问题,请自行尝试,有问题请留言

隐私、权限声明

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

无

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

无

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

无

许可协议

MIT协议