前端vue可以左右滾動的切換的tabs tabs選項卡 滑動影片效果 自動寬度, 下載完整代碼請訪問https://ext.dcloud.net.cn/plugin?id=13003
效果圖如下:




#### 使用方法
```使用方法
swiperTabList: ["2023-06-10","2023-06-11","2023-06-12","2023-06-13","2023-06-14","2023-06-15"], //導航串列
swiperTabIdx: 0,
swiperColor: '#161616', //導航欄字體未選中前顏色
swiperCurrentColor: '#1D63FF', //選中當前導航欄字體顏色
curSwiperWidth: '26%', //當前導航的寬度 % upx rpx px (導航超出可左右滑動 )
curSwiperHeight: 96, //當前導航的高度度 rpx px
curSwiperLineShow: true, //是否顯示導航欄的線條 (線條距離標題太近的話可自行修改.swiperLine的css)
curSwiperLineActiveBg: '#1D63FF', //當前選中的導航欄線條顏色
curSwiperLineActiveWidth: '60%', //當前選中的導航欄線條的寬度 upx rpx px
curSwiperLineActiveHeight: '2px', //當前選中的導航欄線條的高度度 upx rpx px
<!--組件-->
<ccSwiperTabs :swiperTabList='swiperTabList' :swiperTabIdx='swiperTabIdx'
:curSwiperWidth='curSwiperWidth' :curSwiperHeight='curSwiperHeight' :swiperColor='swiperColor'
:swiperCurrentColor='swiperCurrentColor' :curSwiperLineShow="curSwiperLineShow"
:curSwiperLineActive :curSwiperLineActiveHeight="curSwiperLineActiveHeight"
:curSwiperLineActiveBg="curSwiperLineActiveBg"
@change="CurrentTab">
</ccSwiperTabs>
```
#### HTML代碼部分
```html
<template>
<view >
<!--組件-->
<ccSwiperTabs :swiperTabList='swiperTabList' :swiperTabIdx='swiperTabIdx'
:curSwiperWidth='curSwiperWidth' :curSwiperHeight='curSwiperHeight' :swiperColor='swiperColor'
:swiperCurrentColor='swiperCurrentColor' :curSwiperLineShow="curSwiperLineShow"
:curSwiperLineActive :curSwiperLineActiveHeight="curSwiperLineActiveHeight"
:curSwiperLineActiveBg="curSwiperLineActiveBg"
@change="CurrentTab">
</ccSwiperTabs>
<!-- radioData:單選資料 curIndex:當前選擇序列 @change:單選事件 -->
<ccRadioView :radioData="https://www.cnblogs.com/ccVue/archive/2023/06/12/items" :curIndex="current" @change="radioChange"></ccRadioView>
<button type="primary" @click="submitAppointment">提交預約</button>
</view>
</template>
```
#### JS代碼 (引入組件 填充資料)
```javascript
<script>
import ccSwiperTabs from '../../components/ccSwiperTabs.vue'
import ccRadioView from '../../components/ccRadioView.vue'
export default {
components: {
ccSwiperTabs,
ccRadioView
},
data() {
return {
swiperTabList: ["2023-06-10","2023-06-11","2023-06-12","2023-06-13","2023-06-14","2023-06-15"], //導航串列
swiperTabIdx: 0,
swiperColor: '#161616', //導航欄字體未選中前顏色
swiperCurrentColor: '#1D63FF', //選中當前導航欄字體顏色
curSwiperWidth: '26%', //當前導航的寬度 % upx rpx px (導航超出可左右滑動 )
curSwiperHeight: 96, //當前導航的高度度 rpx px
curSwiperLineShow: true, //是否顯示導航欄的線條 (線條距離標題太近的話可自行修改.swiperLine的css)
curSwiperLineActiveBg: '#1D63FF', //當前選中的導航欄線條顏色
curSwiperLineActiveWidth: '60%', //當前選中的導航欄線條的寬度 upx rpx px
curSwiperLineActiveHeight: '2px', //當前選中的導航欄線條的高度度 upx rpx px
items: [{
value: '1',
name: '上午9:00-10:00'
},
{
value: '2',
name: '上午10:00-11:00',
checked: ''
},
{
value: '3',
name: '上午11:00-12:00',
},
{
value: '4',
name: '下午13:00-14:00',
},
{
value: '5',
name: '下午14:00-15:00',
},
{
value: '6',
name: '下午15:00-16:00',
},
{
value: '7',
name: '下午16:00-17:00',
},
{
value: '8',
name: '下午17:00-18:00',
},
],
current: 0,
}
},
onLoad() {
},
methods: {
submitAppointment(){
uni.showModal({
title:'預約資料',
content:"日期選擇 = " + this.swiperTabList[this.swiperTabIdx] + " 時間段選擇 = " + this.items[this.current].name
})
},
//tab點擊事件 自行完善需要的代碼
CurrentTab: function(index, item) {
this.swiperTabIdx = index;
console.log('日期選擇' + item + '\n序列' + index)
},
radioChange: function(evt) {
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].value =https://www.cnblogs.com/ccVue/archive/2023/06/12/== evt.target.value) {
this.current = i;
break;
}
}
},
}
}
</script>
```
#### CSS
```css
<style>
.content {
display: flex;
flex-direction: column;
}
.submitBtn {
width: 90%;
margin-top: 86rpx;
}
</style>
```
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/555010.html
標籤:其他
下一篇:返回列表
