Front-end adaptive text width underline tabs can set the underline color

With the development of technology, the complexity of development is getting higher and higher. The traditional development method makes a system into a whole application. It often happens that a small change or the addition of a small function may cause the overall logic to change. The modification affects the whole body. Through component development, individual development and maintenance can be effectively achieved, and they can be combined at will. Greatly improve low development efficiency and reduce maintenance costs.

Componentization is the only way for any front-end application with complex business scenarios and products after multiple iterations. Componentization requires more than just the module splitting and decoupling seen on the surface. There is also a lot of work behind it to support componentization, such as module splitting strategies based on business characteristics, interaction methods between modules, and building systems. etc.

The components introduced in this article are:

The front-end adaptive text width underline tabs can set the underline color. To download the complete code, please visit the uni-app plug-in market address: https://ext.dcloud.net.cn/plugin?id=12876

 For more information on front-end components, please follow the WeChat public account: Front-end component development

The rendering is as follows:

fb03efc88172f2527dfb6e9a6bdc3977.png

The implementation code is as follows:

#### Instructions

```How to use

<!-- v-model: select sequence tabs: select array myColor: underline color spaceLeft: tabs spacing height: set height @change:tabs switching event -->

<ccScrollTabs v-model="tabIndex" :tabs="tabs" @change="tabChange"></ccScrollTabs>

```

#### HTML code part

```html

<template>

<view class="content">

<view style="margin: 10px;">Default settings</view>

<ccScrollTabs v-model="tabIndex" :tabs="tabs" @change="tabChange"></ccScrollTabs>

<view style="margin: 10px;color: #88888;">Set underline color</view>

<ccScrollTabs v-model="tabIndexTwo" myColor="red" :tabs="tabs" @change="tabChange"></ccScrollTabs>

<view style="margin: 10px;color: #88888;">Set spacing</view>

<ccScrollTabs v-model="tabIndexThree" spaceLeft="20" :tabs="tabs" @change="tabChange"></ccScrollTabs>

<view style="margin: 10px;color: #88888;">Set line height</view>

<ccScrollTabs v-model="tabIndexfour" myColor="red" height="90" :tabs="tabs" @change="tabChange"></ccScrollTabs>

<view style="height: 300px;background-color: antiquewhite;"></view>

</view>

</template>

```

#### JS code (introducing components to fill in data)

```javascript

<script>

import ccScrollTabs from '../../components/cc-scrollTabs/cc-scrollTabs.vue'

export default {

components: {

ccScrollTabs

},

data() {

return {

tabIndex: 0,

tabs: ['Information', 'Sports', 'Video', 'Live', 'Phoenix TV', 'Government Affairs', 'Beautiful China', 'Finance', 'Entertainment', 'Fashion', 'Car', ' real estate'],

tabIndexTwo: 0,

tabIndexThree: 0,

tabIndexfour: 0

}

},

methods: {

tabChange(e) {

console.log("Switch tag = " + JSON.stringify(e));

}

}

}

</script>

```

#### CSS

```css

<style>

.content {

display: flex;

flex-direction: column;

}

.logo {

height: 200rpx;

width: 200rpx;

margin-top: 200rpx;

margin-left: auto;

margin-right: auto;

margin-bottom: 50rpx;

}

.text-area {

display: flex;

justify-content: center;

}

.title {

font-size: 36rpx;

color: #8f8f94;

}

</style>

```

Guess you like

Origin blog.csdn.net/chenchuang0128/article/details/131058256