成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

小程序TAB列表切換內(nèi)容動(dòng)態(tài)變化,scrollview高度根據(jù)內(nèi)容動(dòng)態(tài)獲取

miya / 1672人閱讀

摘要:樣式代碼切換導(dǎo)航超出自動(dòng)隱藏文字隱藏后添加省略號(hào)強(qiáng)制不換行代碼切換導(dǎo)航條切換事件進(jìn)入頁面顯示正在加載的圖標(biāo)正在加載中獲取到數(shù)據(jù)后隱藏正在加載圖標(biāo)獲取的數(shù)據(jù)截取數(shù)組下標(biāo)的數(shù)據(jù)獲取系統(tǒng)信息設(shè)備的高度等于內(nèi)容的高度成功后的截圖

滑動(dòng)tab選項(xiàng)卡
一、在小程序里面tab選項(xiàng)卡是用的是自帶的swiper組件,下面直接上代碼
    
  
    運(yùn)動(dòng)專區(qū)
    美食專區(qū)
  
  
  
  
    
      
      
        
          
            {{original}}
            
              
            
            
                {{item.addtime}}
                {{item.title}}
                
                  {{originalContent}}
                
            
          
        
      
     
  


    
      
        
          
            
              {{original}}
              
                
              
              
                  {{item.addtime}}
                  {{item.title}}
                  
                    {{originalContent}}
                  
              
            
          
        
       
    
  
ps:大家都知道小程序是不能操作DOM的,所以這里用getSystemInfo獲取設(shè)備高度,scrollview在這里是一個(gè)內(nèi)嵌的框架,列表在框架內(nèi)滾動(dòng),它的高度其實(shí)就是屏幕的高度,不是里邊列表項(xiàng)目的高度,
所以這里設(shè)置max-height等都是無效的。



樣式代碼:

.container{
  width:100%;
  height: 100%; 
  background:#eee;
}

/*tab切換導(dǎo)航 */
.tab{
  width: 100%;
  color:#666666;
  height: 70rpx;
  font-size:28rpx;
  display: inline-block;
  text-align: center;
  background: #fff;
}
.tab-list{
  height: 70rpx;
  line-height: 70rpx;
  width: 50%;
  display: inline-block;
  z-index: 1000;
}
.active{
  border-bottom:4rpx solid #FD9D80;
}
.swiper-box{
  width: 100%;
  max-height:9999px; 
  display: block;
}


.video-detail-list{
  margin-top:16rpx;
  width:100%;
  background: #fff;

}
.video-detail-list .original-name{
   height: 80rpx;
   line-height: 80rpx; 
  text-align: center;
  display: block;
  font-size:28rpx;
}
.original-name{
  color:#999999;
}
.original-video{
  text-align: center;
}
.original-video video{
  width: 640rpx;
}
.original-video video{
  border-radius:16rpx;
}
.original-video-explain{
  width: 640rpx;
  margin-left:50rpx;
}
.original-video-date{
  font-size:28rpx;
  color:#6C6C6C;
}
.original-video-date text{
  display: inline-block;
}
.original-video-name{
  text-align: center;
  width: 55%;
  margin-top:8rpx;
  float:right;
  font-size:28rpx;
  color:#6C6C6C;
  overflow: hidden;  /* 超出自動(dòng)隱藏 */
  text-overflow:ellipsis;  /* 文字隱藏后添加省略號(hào) */
  white-space:nowrap;    /*  強(qiáng)制不換行 */
}
.original-video-detail{
  color:#A1A1A1;
  height: 30rpx;
  font-size:20rpx;
  /* margin-top:-10rpx; */
  
}
.original-video-detail text{
    width: 100%;
    display: -webkit-box;
    word-break: break-all;
    -webkit-box-orient: vertical;
    -webkit-line-clamp:3;
    overflow: hidden;
    text-overflow:ellipsis;
    color:#666;
}

js代碼:

var videoUrl = "http://t.jingduhealth.com/index/xcsvideo"
var app = getApp()
Page({
  data: {
    true:true,
    video:[],
    winWidth: 0,
    winHeight: 0, 
    currentTab: 0,  // tab切換 
  },
  //tab導(dǎo)航條切換事件
  bindChange:function(e){
    var that = this;
    that.setData({
      currentTab: e.detail.current
    })
  },
  switchNav:function(e){
    var that = this;
    if (this.data.currentTab === e.target.dataset.current){
      return false;
    }else{
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },
  onLoad: function () {
    var that = this;
    //進(jìn)入頁面顯示正在加載的圖標(biāo)
    wx.showToast({
      title: "正在加載中...",
      icon: "loading",
      duration: 10000
    })
    wx.request({
      url:videoUrl,
      data:{},
      header:{
        "ContentType":"application/json"
      },
      success: function (res){
        //獲取到數(shù)據(jù)后隱藏正在加載圖標(biāo)
        wx.hideLoading();
        console.log(res.data)
        that.setData({
            video:res.data.slice(0,2)  //獲取的數(shù)據(jù)截取數(shù)組下標(biāo)0-2的數(shù)據(jù)
        })
      }
    })

    //獲取系統(tǒng)信息
    wx.getSystemInfo({
      success:function(res){
        that.setData({
          clientHeight: res.windowHeight   //設(shè)備的高度等于scroll-view內(nèi)容的高度
        })
      }
    })
  }
})
 
成功后的截圖

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/88666.html

相關(guān)文章

  • Android 實(shí)現(xiàn)錨點(diǎn)定位

    摘要:原文鏈接相信做前端的都做過頁面錨點(diǎn)定位的功能,通過去設(shè)置頁面內(nèi)錨點(diǎn)定位跳轉(zhuǎn)。本篇文章就使用來實(shí)現(xiàn)錨點(diǎn)定位的功能。寫到這里,的錨點(diǎn)定位成型了,在實(shí)際項(xiàng)目中,我們還可以使用來完成同樣的效果,后續(xù)的話會(huì)帶來這樣的文章。 原文鏈接:https://mp.weixin.qq.com/s/EYyTBtM9qCdmB9nlDEF-3w 相信做前端的都做過頁面錨點(diǎn)定位的功能,通過 去設(shè)置頁面內(nèi)錨點(diǎn)定...

    dendoink 評論0 收藏0

發(fā)表評論

0條評論

miya

|高級(jí)講師

TA的文章

閱讀更多
最新活動(dòng)
閱讀需要支付1元查看
<