DynamicTabs_gz

一个简易tabs标签页,只需创建该类的实例,按需传入配置即可在页面上创建

لا ينبغي أن لا يتم تثبيت هذا السكريت مباشرة. هو مكتبة لسكبتات لتشمل مع التوجيه الفوقية // @require https://update.greatest.deepsurf.us/scripts/517538/1485921/DynamicTabs_gz.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 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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

المؤلف
hgztask
الإصدار
0.2
تم إنشاؤه
15-11-2024
تم تحديثه
17-11-2024
الحجم
11.4 KB
الترخيص
Apache-2.0

DynamicTabs_gz

说明

  1. 一个简易Tabs标签页,只需创建该类的实例,按需传入选项卡配置即可在页面上创建, 支持设置自定义样式。
  2. 支持手动切换激活的选项卡。
  3. 支持动态修改选项卡位置。

实例

 // 示例选项卡配置
const tabsConfig = [
    //id不要重复,title也不可重复
    {id: 'tab1', title: '选项卡1', content: '<p>这是选项卡1的内容。</p>'},
    {id: 'tab2', title: '选项卡2', content: '<p>这是选项卡2的内容。</p>'},
    {id: 'tab3', title: '选项卡3', content: '<p>这是选项卡3的内容。</p>'},
];

// 自定义样式和事件处理类名
const options = {
    // 设置标签页位置,默认为 top,可选值有 top、bottom、left、right
    tabPosition: "left",
    /**
     *  追加自定义样式
     */
    styles: `
                /* 自定义样式 */
                .my-custom-tab-button {
                    font-size: 16px;
                }
                .my-custom-tab-content {
                    background-color: #f9f9f9;
                }
            `,
    // 自定义类名
    classes: {
        // 选项卡按钮样式
        tabButton: 'my-custom-tab-button',
        tabButtonActive: 'my-custom-tab-button-active',
        tabContent: 'my-custom-tab-content',
        tabContentActive: 'my-custom-tab-content-active'
    },
    backgroundColor: '#eee',
    borderColor: '#ddd',
    textColor: '#333',
    fontWeight: 'bold',
    activeBackgroundColor: '#0056b3',
    activeTextColor: '#fff',
    contentBorderColor: '#bbb',
    contentBackgroundColor: '#ffffff',
    onTabClick: (id, title, content) => {
        console.log(id, title, content)
    },
};

// 创建动态选项卡实例
try {
    const dynamicTabsGz = new DynamicTabs_gz('#tabs-container', tabsConfig, options);
    //手动切换激活的选项卡
    //通过标题激活选项卡
    dynamicTabsGz.activateTabTitle("选项卡2");
    //通过id激活选项卡
    dynamicTabsGz.activateTabId("tab1");
    //动态修改选项卡位置
    dynamicTabsGz.setTabPosition("right");
} catch (error) {
    console.error(error.message);
}