<view class="evaluationItem">
<scroll-view class="uni-swiper-tab" scroll-x :style="'height:'+scrollH+'px'">
<view class="scrollx_items" >
<text v-for="item,index in modelList" :key="index" :class="{activeItem:index==currentEvaluationIndex}" @click="modelListItem(item,index)">{
{item}}</text>
</view>
</scroll-view>
</view>
This code is a horizontally scrolling tab page implemented using the uni-app framework, which uses <scroll-view>
components to achieve horizontal scrolling, and scroll-x
specifies the scrolling direction as horizontal through attributes. <view>
Instructions are used in the component v-for
to render modelList
each element in the array, and :class
an object is bound with it. When the index of the current element is equal to currentEvaluationIndex
, the properties in the object activeItem
are set to true
, thus realizing the selected state of the tab page. Finally, <text>
the component is bound to an @click
event. When the user clicks the tab, modelListItem
the method will be triggered, and the currently clicked element and index will be passed into the method as parameters.