uni-app实现滑动切换效果

在对于uni-app框架了解之后,今天就实现一个滚动切换tab效果,这个很常见的一个效果,最后封装成一个组件,便于以后使用,写这个需要引入uni官方提供的uni.css样式,用到了写好的样式,就不需要自己写了

uni-app实现滑动切换效果

 

 

 这种切换无论是在app端还是小程序或者H5页面都是很常见的功能。对于这种功能,为单独封装成功组件,方便每个页面都能用到,

tab顶部导航栏

页面布局,使用uni-app提供的scroll-view组件。

<template> <view class="uni-tab-bar"> <scroll-view class="uni-swiper-tab" scroll-x> <block v-for="(tab,index) in tabBars" :key="tab.id" :style="scrollStyle"> <view class="swiper-tab-list" :class="{'active' : tabIndex==index}" @tap="tabtap(index)" :style="scrollItemStyle" > {{tab.name}} {{tab.num?tab.num:""}} <view class="swiper-tab-line"></view> </view> </block> </scroll-view> </view> </template>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zywffw.html