gz-component

一个常用的组件库

بۇ قوليازمىنى بىۋاسىتە قاچىلاشقا بولمايدۇ. بۇ باشقا قوليازمىلارنىڭ ئىشلىتىشى ئۈچۈن تەمىنلەنگەن ئامبار بولۇپ، ئىشلىتىش ئۈچۈن مېتا كۆرسەتمىسىگە قىستۇرىدىغان كود: // @require https://update.greasyfork.org/scripts/524094/1522518/gz-component.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

ئاپتورى
hgztask
نەشرى
1.0.1
قۇرۇلغان ۋاقتى
2025-01-18
يېڭىلانغان ۋاقتى
2025-01-18
Size
6.9 KB
ئىجازەتنامىسى
Apache-2.0

gz-component(gz组件)


目前已有的组件

  1. SheetDialog sheet对话框

使用方法

  • 通过 new gz.组件名称(配置项) 创建组件实例

SheetDialog sheet对话框

  • 使用方法

// 创建实例
const sheetDialog = new gz.SheetDialog({
    title: '标题',
    //是否点击遮罩关闭对话框
    closeOnOverlayClick: false,
    //选项组
    options: [
        //直接指定选项内容
        '选项1',
        //也可以通过对象的形式指定
        {
            //使用label作为选项内容
            label: '选项2',
            //使用其他自定义key作为选项的属性
            value1: 'value1',
            value2: 'value2',
            value3: 'value3'
        },
        {
            //同上
            label: '选项3',
            value: '选项3的值',
            /**
             * 该属性指定点击事件
             * @param event 事件对象
             * @param attrs {[{name:string,value:string}]} 该选项的属性
             * @param This {SheetDialog} 当前组件实例
             * @returns {boolean} 如果返回true则阻止全局选项的点击事件,否则继续执行全局选项的点击事件
             */
            event: (event, attrs, This) => {
                const label = event.target.textContent.trim();
                console.log(label, attrs);
                console.log(This.getAllOptionAttrs());
                //是否阻止全局选项的点击事件
                return true
            }
        }
    ],
    /**
     * 该实例的全局选项点击事件
     * @param event 事件对象
     * @param attrs {[{name:string,value:string}]} 当前选项的属性
     * @param This {SheetDialog} 当前组件实例
     * @returns {boolean} 如果返回true则阻止全局选项的点击事件,否则继续执行全局选项的点击事件
     *
     */
    optionEvent: (event, attrs, This) => {
        const targetButEl = event.target;
        const label = targetButEl.textContent;
        console.log(This);
        console.log(`点击了${label}`, attrs, targetButEl);
        return true;
    }
});

//添加到网页body中
sheetDialog.addBody()
//获取实例所有选项的属性
const allOptionAttrs = sheetDialog.getAllOptionAttrs();

//设置实例的全局选项点击事件
sheetDialog.setOptionEvent(回调事件);

//销毁实例并在页面中移除内容
sheetDialog.destroy();