Home > Web Front-end > JS Tutorial > body text

How to use YDUI's ScrollTab component in WeChat applet

亚连
Release: 2018-06-08 11:42:38
Original
2006 people have browsed it

This article mainly introduces the ScrollTab component of WeChat applet to implement YDUI in detail, and the scrolling tab effect has a certain reference value. Interested friends can refer to it

The example of this article is Everyone has shared the specific code for the WeChat applet to achieve the scrolling tab effect for your reference. The specific content is as follows

DEMO download

Rendering

YDUI’s ScrollTab (scrolling option Card)

WXML

<!--导航 -->
<view class="tui-fixed-left">
 <scroll-view class="tui-city-scroll" scroll-x="true">
  <text bindtap="getStatus" id="NAV{{index}}" class="tui-nav-li {{index === status ? &#39;tui-nav-active&#39; : &#39;&#39;}}" data-index="{{index}}" wx:for="{{navList}}">{{item}}</text>
 </scroll-view>
</view>
<!--列表滚动区 -->
 <view class="tui-fixed-y">
 <scroll-view class="tui-city-scroll-y" scroll-y="true" scroll-into-view="NAV{{status}}" scroll-with-animation="true">
  <view wx:for="{{navList}}">
   <view id="NAV{{index}}" class="tui-list-head">{{item}}</view>
   <view class="tui-list-li">{{item}} 列表 {{index}}</view>
  </view>
 </scroll-view>
</view>
Copy after login

WXSS

.tui-fixed-x{
 margin-left: 130px;
 position: fixed;
 top: 0;
 left: 0;
}
.tui-fixed-left{
 width: 120px;
 height: 100%;
 border-right: 1px solid #dfdfdf;
 position: fixed;
 background-color: #f5f5f5;
 top: 0;
 left: 0;
}
.tui-list-head{
 background-color: #fff;
 margin-bottom: 15px;
}
.tui-city-scroll{
 width: 100%;
}
.tui-nav-li{
 font-size: 30rpx;
 padding: 0 10px;
 height: 100rpx;
 line-height: 100rpx;
 width: 100px;
 display: block;
 border-bottom: 1px solid #dfdfdf;
 position: relative;
 z-index: 10;
}
.tui-nav-active{
 background-color: #fff;
}

.tui-fixed-y{
 margin-left: 120px;
 padding-left: 10px;
 padding-right: 10px;
 height: 100%;
 position: fixed;
 bottom: 0;
 right: 0;
}
.tui-city-scroll-y{
 height: 100%;
 box-sizing: border-box;
}
.tui-list-head{
 height: 50px;
 line-height: 50px;
 text-align: center;
 font-size: 30rpx;
 color: blue;
}
.tui-list-li{
 height: 400px;
 padding: 10rpx;
 color: #fff;
 font-size: 50rpx;
 background-color: lightgreen;
}
Copy after login

JS

Page({
 data: {
  navList: [&#39;今日特惠&#39;, &#39;烟灶推荐&#39;, &#39;净水饮水推荐&#39;, &#39;洗碗机推荐&#39;, &#39;电热推荐&#39;, &#39;燃热推荐&#39;, &#39;消毒柜推荐&#39;, &#39;嵌入式推荐&#39;, &#39;商用电器&#39;, &#39;活动说明&#39;],
  status: 0
 },
 getStatus(e) {
  this.setData({ status: e.currentTarget.dataset.index })
 }
})
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to implement the image loading component in vue

##Why will Node.js become a web application development?

How to get the file upload progress in Node.js?

The above is the detailed content of How to use YDUI's ScrollTab component in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!