网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序實現各種特效實例

發布時間:2018-04-26 12:01 所屬欄目:小程序開發教程

寫在前面

 

最近在負責一個微信小程序的前端以及前后端接口的對接的項目,整體上所有頁面的布局我都已經搭建完成,里面有一些常用的特效,總結一下,希望對大家和我都能有所幫助

實例1:滾動tab選項卡

 

先看一下效果圖吧,能夠點擊菜單或滑動頁面切換,tab菜單部分可以實現左右滾動

好了,看一下我的源碼吧!<喜歡的話拿走不謝喲>

1、wxml

  1. <!-- tab header -->
  2. <scroll-view scroll-x="true" class="tab-h" scroll-left="{{scrollLeft}}">
  3. <view class="tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="swichNav">全部</view>
  4. <view class="tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="swichNav">營銷系統</view>
  5. <view class="tab-item {{currentTab==2?'active':''}}" data-current="2" bindtap="swichNav">家居建材</view>
  6. <view class="tab-item {{currentTab==3?'active':''}}" data-current="3" bindtap="swichNav">美妝護膚</view>
  7. <view class="tab-item {{currentTab==4?'active':''}}" data-current="4" bindtap="swichNav">數碼電器</view>
  8. <view class="tab-item {{currentTab==5?'active':''}}" data-current="5" bindtap="swichNav">母嬰玩具</view>
  9. <view class="tab-item {{currentTab==6?'active':''}}" data-current="6" bindtap="swichNav">零元購活動</view>
  10. </scroll-view>
  11. <!-- tab content -->
  12. <swiper class="tab-content" current="{{currentTab}}" duration="300" bindchange="switchTab" style="max-height:{{winHeight}}rpx">
  13. <swiper-item wx:for="{{[0,1,2,3,4,5,6]}}">
  14. <scroll-view scroll-y="true" class="scoll-h">
  15. <block wx:for="{{[1,2,3,4,5,6,7]}}" wx:key="*this">
  16. <view class='goods-Wrapper'>
  17. <image mode='widthFix' class="goods-img" src='../../image/goods1.jpg'></image>
  18. <view class="goods-info">
  19. <view>周邊團門店微營銷系統年費</view>
  20. <view>
  21. <text class='price'>¥298.00</text>
  22. <text class='line-delete'>
  23. ¥298.00
  24. </text>
  25. <label>
  26. <button><image mode='widthFix' src='../../image/icon1.png'></image>1人團</button>
  27. <button><image mode='widthFix' src='../../image/icon2.png'></image>去開團</button>
  28. </label>
  29. </view>
  30. </view>
  31. </view>
  32. </block>
  33. </scroll-view>
  34. </swiper-item>
  35. </swiper>
 
2、wxss <我只展示了tab菜單處的wxss,頁面的樣式就不在列出>
  1. .tab-h {
  2. height: 80rpx;
  3. width: 100%;
  4. box-sizing: border-box;
  5. overflow: hidden;
  6. line-height: 80rpx;
  7. background: #f7f7f7;
  8. font-size: 14px;
  9. white-space: nowrap;
  10. position: fixed;
  11. top: 0;
  12. left: 0;
  13. z-index: 99;
  14. }
  15.  
  16. .tab-item {
  17. margin: 0 36rpx;
  18. display: inline-block;
  19. }
  20.  
  21. .tab-item.active {
  22. color: #4675f9;
  23. position: relative;
  24. }
  25.  
  26. .tab-h .tab-item.active:after {
  27. content: "";
  28. display: block;
  29. height: 8rpx;
  30. width: 115rpx;
  31. background: #4675f9;
  32. position: absolute;
  33. bottom: 0;
  34. left: 5rpx;
  35. border-radius: 16rpx;
  36. }
  37.  
  38. .tab-h .tab-item:nth-child(1).active:after {
  39. width: 52rpx;
  40. }
3、js
  1. var app = getApp();
  2. Page({
  3. data: {
  4. winHeight: "",//窗口高度
  5. currentTab: 0, //預設當前項的值
  6. scrollLeft: 0, //tab標題的滾動條位置
  7. expertList: [{ //假數據
  8. img: "",
  9. name: "",
  10. tag: "",
  11. answer: 134,
  12. listen: 2234
  13. }]
  14. },
  15. // 滾動切換標簽樣式
  16. switchTab: function (e) {
  17. this.setData({
  18. currentTab: e.detail.current
  19. });
  20. this.checkCor();
  21. },
  22. // 點擊標題切換當前頁時改變樣式
  23. swichNav: function (e) {
  24. var cur = e.target.dataset.current;
  25. if (this.data.currentTaB == cur) { return false;


易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/24105.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×