Introduction to JavaScript framework (xmlplus) components (5) Tabbar
xmlplus is a JavaScriptframework used for rapid development of front-end and back-end projects. This article mainly introduces the tab of the xmlplus component design series, which has certain reference value. Interested friends can refer to
This chapter will design a tab component, which is handheld It is often used on equipment. The following is a schematic diagram:
Tab composition
Before the specific implementation, Imagining how the target component is used will be of great help to the design. By inspection, the tab component can be divided into a container part and a child part, as shown in the following XML structure.
<Tabbar id="tabbar"> <TabItem id="home" label="首页"/> <TabItem id="setting" label="设置"/> <TabItem id="logs" label="日志"/> <TabItem id="about" label="关于"/> </Tabbar>
Now we switch our attention to the sub-item part of the tab component and see how the sub-item part is decomposed. From the diagram, you can see that the child section can be broken down into a child container and a child section that contains an icon and a text.
<a id="tabitem"> <Icon id="icon"/> <span id="label">首页</span> </a>
So, now our goal is very clear, mainly designing three components: the icon component Icon, the sub-item TabItem of the tab component, and the container Tabbar of the tab component.
Structural diagram
Because this component is relatively simple, the three sub-components can be placed at the same level. But please note that we also have four icon components and can create a child to hold them. Our component structure diagram is given below:
Tabbar/
├── Tabbar
├── TabItem
└── Icon/
├─ ─ About
├── Home
├── Logs
└── Setting
##Icon implementation
About: { xml: `<svg width="48" height="48" viewBox="0 0 1024 1024"> <path d="M507.577907 23.272727C240.142852..."/> </svg>` }, Home: { xml: `<svg width="48" height="48" viewBox="0 0 1024 1024"> <path d="M949.082218 519.343245 508.704442..."/> </svg>` }, Logs: { xml: `<svg width="48" height="48" viewBox="0 0 1024 1024"> <path d="M576 125.344l32 0 0 64-32 0 0-64Z..."/> </svg>` }, Setting: { xml: `<svg width="48" height="48" viewBox="0 0 1024 1024"> <path d="M512 336.664c-96.68 0-175.336 78...."/> </svg>` }
xmlplus("ui", function (xp, $_, t) { $_().imports({Tabbar: {... }, TabItem: {...}}); $_("icon").imports({--这里包含了四个图标组件--}); });
Icon: { css: "#icon { width: 1.5em; height: 1.5em; display: inline-block; }", opt: { icon: "about" }, xml: `<span id="icon"/>`, fun: function (sys, items, opts) { sys.icon.replace("icon/" + opts.icon).addClass("#icon"); } }
function item of this component creates an icon component based on the input icon type and replaces the existing span element object . Note that you need to re-add the style after replacement.
Implementation of sub-items
TabItem: { css: "这里是样式项部分,为便于组件整体展示,略去...", map: {"attrs": { icon: "id->icon" } }, xml: `<a id="tabitem"> <Icon id="icon"/> <span id="label">首页</span> </a>`, fun: function (sys, items, opts) { sys.label.text(opts.label); function select() { sys.tabitem.addClass("#primary"); } function unselect() { sys.tabitem.removeClass("#primary"); } return { select: select, unselect: unselect }; } }
interface for switching between selected and unselected states when switching options. For use by tab containers.
Implementation of tab
Tabbar: { css: "这里是样式项部分,为便于组件整体展示,略去...", xml: `<nav id="tabbar"/>`, fun: function (sys, items, opts) { var sel = this.first(); this.on("touchend", "./*[@id]", function (e) { sel.value().unselect(); (sel = this).value().select(); this.trigger("switch", this.toString()); }); if (sel) sel.value().select(); } }
xmlplus("example", function (xp, $_, t) { $_().imports({ Index: { xml: `<Footer id='footer'/>`, fun: function (sys, items, opts) { this.on("switch", (e, target) => console.log(target)); } }, Footer: { xml: `<Tabbar id="footer"> <TabItem id="home" label="首页"/> <TabItem id="setting" label="设置"/> <TabItem id="logs" label="日志"/> <TabItem id="about" label="关于"/> </Tabbar>` } }); });
View stack component we will introduce later to perform switching operations between pages.
This series of articles is based on the xmlplus framework. If you don’t know much about xmlplus, you can visit www.xmlplus.cn. Detailed getting started documentation is available here. 【Related recommendations】1. 2.JavaScript Chinese Reference Manual
3.php.cn Dugu Jiujian (3) - JavaScript video tutorial
The above is the detailed content of Introduction to JavaScript framework (xmlplus) components (5) Tabbar. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Several Windows users have complained that when they try to access some websites on Google Chrome browser on their systems, they are unable to access the web pages. It also displays a message on the browser saying "The site cannot be reached" with error code ERR_ADDRESS_UNREACHABLE. There could be many potential reasons behind this issue, it could be due to website server issues, proxy server settings, unstable internet connection, etc. If you encounter similar problems, don't panic. After deeply analyzing the problem in this article, we got a bunch of solutions. Before proceeding, try the following workarounds: Try checking if the user is trying to access the site from other devices and there are no issues, then this

Logitech GHub is software that allows users to manage their Logitech peripherals. This software is compatible with Windows 11. However, some users reported that Logitech GHub does not work for them in Windows 11. Our readers have reported that when they try to launch the software, it gets stuck loading. Therefore, they cannot use the software when it does not open for them. Have you also tried fixing LogitechGHub not working in Windows 11? If so, the potential solutions below may launch LogitechGHub. What's the reason why Logitech GHub doesn't work in Windows 11? with many other

MSIAfterburner is an overclocking tool suitable for most graphics cards. Apart from that, you can also use it to monitor the performance of your system. But some users reported that MSIAfterburner is not working in Windows 11. This may be due to several reasons, which we discuss in the following sections. However, when this happens, it prevents you from changing the performance or monitoring it while playing the game. As expected, this poses a significant challenge to gamers. That’s why we’ve dedicated this tutorial to help you understand the issue and walk you through the most effective fixes for MSIAfterburned not working in Windows 11 issue.

One of the features that comes with Windows File Explorer is the preview pane, which displays a preview of the file you selected. This means you can view the contents of the file before opening it. The preview pane of File Explorer provides previews for different types of files such as Office-related documents, PDFs, text files, images, and videos. It usually works fine, but sometimes the file preview isn't available. Recently, many Windows 11 users have raised the issue that File Explorer’s preview pane is not working and they are unable to view file previews. Are you facing the issue of preview pane not working on your Windows computer? Then, continue reading this article. Here we have compiled a list of fixes that can help you fix

The operating system looks much better than its predecessor and has gamer-oriented features like AutoHDR and DirectStorage, but Valorant players have had some trouble launching the game. This is not the first issue faced by gamers earlier, Valorant not opening on Windows 11 is another issue plaguing them but we have covered the ways to fix it. Now it seems that Valorant players who switched to Windows 11 are facing issues due to Secure Boot and TPM2.0 services, which causes the game menu to only show an exit option while running. Many users are getting the VAN1067 error, but it shouldn't be a cause for alarm

The latest version of the Opera browser includes a new automatic video popup feature. Using this feature, you will notice that the video will pop up automatically when you navigate to another tab in the browser. It has been noticed that this pop-up video can be resized and moved around the screen. When you navigate back to the Videos tab, it resumes and the floating window disappears. The video pop-up feature is useful for multitasking users who like to watch videos while working. However, not every Opera user will like this automatic video popup feature. If you are one of those Opera browser users who are annoyed by videos popping up every time you change tabs, then you have found the right post. Here we detail how to disable this popup in Opera

Almost every high-end game we play relies on DirectX to run efficiently. However, some users reported encountering the DirectX function GetDeviceRemovedReasonfailedwith followed by the error reason. The above reasons are not self-evident to the average user and require some level of research to determine the root cause and the most effective solution. To make things easier, we've dedicated this tutorial to this problem. In the following sections, we will help you identify the potential causes and walk you through the troubleshooting steps to eliminate the DirectX function GetDeviceRemovedReasonfailedwitherror. what causes

This operation requires an interactive window station which is a rather strange bug. Software windows that allow users to interact with the app are not open, you need to enable them. This bug has been linked to the 2021 Printing Nightmare vulnerability. However, it continues to this day, affecting your computer and device drivers. Fortunately, it's easy to fix. Why does this error occur in the first place? Before describing how to fix this error, be sure to list the causes of this error. This way, you can take the necessary steps to ensure it doesn't happen again. Corrupted files are messing up your computer files – Corruption can be caused by a variety of reasons, from malware to power outages. It is recommended that you run an SFC scan. You have an overzealous antivirus app – antivirus software sometimes blocks
