12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <template>
-
- <scroll-view show-scrollbar scroll-x='false' scroll-with-animation
- :scroll-into-view=" 'tab-' + scrollIntoView"
- :style="{ height:currentSwiperHeight + 'rpx' }">
- <view class="swiperTab" v-for="(item,index) in swiperTabList" :key='index'
- :style="{ width:currentSwiperWidth,lineHeight:currentSwiperHeight + 'rpx' }"
- :id=" 'tab-' + index " @tap="CurrentTab(index,item)">
-
-
- <text :style="{ color:swiperTabIdx == index ? swiperCurrentColor:swiperColor }">
- {{ item }}
- </text>
-
-
-
- <view class="swiperLine" v-show="currentSwiperLineShow">
- <view class="swiperLineActive"
- :class="[ swiperTabIdx == index && currentSwiperLineAnimatie ?'currentLine':'' ]"
- :style="{
- width:currentSwiperLineActiveWidth,
- height:currentSwiperLineActiveHeight,
- background:currentSwiperLineActiveBg
- }" v-if=" swiperTabIdx == index ">
- </view>
- </view>
-
-
- </view>
- </scroll-view>
- </template>
- <script>
- export default{
- data(){
- return{
- }
- },
- onLoad() { },
- props:{
- scrollIntoView:{ type:Number },
- swiperTabList:{ type:Array },
- swiperTabIdx:{ type:Number },
- swiperColor:{ type:String },
- swiperCurrentColor:{ type:String },
- currentSwiperWidth:{ type:String },
- currentSwiperHeight:{ type:Number },
- currentSwiperLineShow:{ type:Boolean },
- currentSwiperLineActiveWidth:{ type:String },
- currentSwiperLineActiveHeight:{ type:String },
- currentSwiperLineActiveBg:{ type:String },
- currentSwiperLineAnimatie:{ type:Number },
- },
- methods:{
-
- CurrentTab:function (index,item){
- this.$emit('change',index,item);
- },
-
- }
- }
- </script>
- <style>
- .swiperHead scroll-view{
- display: flex;
- flex-direction: row;
- flex-wrap: nowrap;
- white-space: nowrap;
- }
- .swiperTab{
- display: inline-flex;
- flex-direction: column;
- text-align: center;
- position: relative;
- }
- .swiperLine{ position: absolute;bottom:-10px;left: 0;width: 100%;z-index: 10; }
- .swiperLineActive{ margin: 0 auto;border-radius: 30upx; }
- @keyframes currentLine{
- 0%{
- transform: scale(0.5);
- }
- 100%{
- transform: scale(1);
- }
- }
- .currentLine{ animation:currentLine 300ms forwards; }
- </style>
|