Home Web Front-end uni-app How uniapp implements tab function

How uniapp implements tab function

Dec 08, 2020 am 11:28 AM
uni-app Tab

Uniapp's method to implement the tab function: first write an outer frame, fix the tab at the top and use [display: flex]; then use ternary operation to assign a sort respectively, and if selected, add [inv- h-se] style; finally write two different containers and use [v-show] to switch.

How uniapp implements tab function

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, Dell G3 computer.

Uniapp's method of implementing the tab function:

Step instructions:

1. First write an outer frame, then write 2 contents, first Fix the tab at the top using display: flex;, and then write 2 different styles to distinguish between selected and unselected

2. Use ternary operation to assign a sort to them respectively, click When getting the first or second one, if selected, add the inv-h-se style

3. The first one is displayed by default in the return

4. Finally, write 2 different container, use v-show to switch

<template>
        <view>
                <view class="inv-h-w">
                        <view :class="[&#39;inv-h&#39;,Inv==0?&#39;inv-h-se&#39;:&#39;&#39;]" @click="Inv=0">选项卡1</view>
                        <view :class="[&#39;inv-h&#39;,Inv==1?&#39;inv-h-se&#39;:&#39;&#39;]" @click="Inv=1">我是选项卡二</view>
                </view>
                <view class="" v-show="Inv == 0">
                        我是选项卡一
                </view>
                <view class="" v-show="Inv == 1">
                        我是选项卡二
                </view>
        </view>
</template>
 
<script>
        export default {
                data() {
                        return {
                                Inv:0
                        }
                },
                methods: {
                        changeTab(Inv){
                                that.navIdx = Inv;
                                 
                        },
                }
        }
</script>
         
<style>
        .inv-h-w{background-color: #FFFFFF;height: 100upx;display: flex;}
        .inv-h{font-size: 30upx;flex: 1;text-align: center;color: #C9C9C9;height: 100upx;line-height: 100upx;}
        .inv-h-se{color: #5BA7FF;border-bottom: 4upx solid #5BA7FF;}
        page{background-color: #F2F2F2;}
</style>
Copy after login

The effect is as shown:

How uniapp implements tab function

##Related free learning recommendations:

Programming Video

The above is the detailed content of How uniapp implements tab function. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Fix: ERR_ADDRESS_UNREACHABLE error in Google Chrome Fix: ERR_ADDRESS_UNREACHABLE error in Google Chrome May 15, 2023 pm 06:22 PM

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

How to fix preview pane not working in Windows 11 How to fix preview pane not working in Windows 11 Apr 24, 2023 pm 06:46 PM

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

Can't use MSI Afterburner in Windows 11? Try the following fixes. Can't use MSI Afterburner in Windows 11? Try the following fixes. May 09, 2023 am 09:16 AM

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.

Fix: VAN 1067 error when running Valorant on Windows 11 Fix: VAN 1067 error when running Valorant on Windows 11 May 22, 2023 pm 02:41 PM

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

To fix this, you need to use an interactive window station To fix this, you need to use an interactive window station Apr 24, 2023 pm 11:52 PM

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

DirectX function GetDeviceRemovedReason fails with error DirectX function GetDeviceRemovedReason fails with error May 17, 2023 pm 03:38 PM

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

How to disable video autoplay in Opera browser? How to disable video autoplay in Opera browser? Apr 22, 2023 pm 10:43 PM

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

How to Optimize Internet Connection Speed ​​in Windows 11 How to Optimize Internet Connection Speed ​​in Windows 11 Apr 23, 2023 pm 10:46 PM

How to solve the problem of slow network speed in Windows 11? 1. Restart your computer Navigate to the desktop and press Alt+F4 to activate the "Shut down Windows" box. Click the drop-down menu and select Restart from the list of options. Next, click OK. For most problems you encounter in Windows 11, one of the most effective solutions is to simply restart your computer. If it is a background process or error that is causing the problem, restarting the operating system will eliminate it, thus fixing the error. After restarting the computer, check whether the network speed problem of Windows 11 is resolved. 2. Make sure the PC is within range of the router (Wi-Fi network) In the case of a wireless network, the farther the device is from the router, the slower the internet speed will be

See all articles