最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

如何實(shí)現(xiàn)小程序tab欄下劃線動(dòng)畫效果

 更新時(shí)間:2019年05月18日 11:47:20   作者:隨她  
這篇文章主要介紹了如何實(shí)現(xiàn)小程序tab欄下劃線動(dòng)畫效果,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

本文主要介紹了如何實(shí)現(xiàn)小程序tab欄下劃線動(dòng)畫效果,分享給大家,具體如下:

最終效果

實(shí)現(xiàn)

wxml

<view class='abox'>
  <view wx:for="{{title}}" class='{{currentIndex==index?"tabTrue":""}}' bindtap='changeTab' data-aa='{{index}}'>
   {{item}}
  
  </view>
  <view class='b' style="left:{{left}}px"></view>
</view>

wxss

.abox{
 display: flex;
 flex-direction: row;
 width: 100%;
 justify-content: space-around;
 position: relative;
 padding-bottom: 20rpx;
}

.tabTrue{
 color: red;
}
.b{
 background: red;
 height: 4rpx;
 width:64rpx;
 position: absolute;
 bottom: 0;
 transition: all .3s linear;
}

js

Page({
 data: {
  title: ["首頁","掘金","思否","知乎"],
  currentIndex:"0",
  left:""
 },
 changeTab:function(e){
  //console.log(e)
  this.setData({
   currentIndex: e.currentTarget.dataset.aa
  })
  this.changeline(e)
  
 },
 changeline:function(){
  const query = wx.createSelectorQuery()
  var _this = this
  query.select('.tabTrue').boundingClientRect()
  query.exec(function (res) {
   _this.setData({
    left: res[0].left
   })
   //console.log(res[0].left)
  })
 },
 onLoad: function () {
  
  this.changeline(1)
  
 }
})

上面代碼可以實(shí)現(xiàn)效果,這里面最重要的就是通過 changeTab方法獲取有tabtrue這個(gè)class的標(biāo)簽,獲取到標(biāo)簽的left值。

相關(guān)文章

最新評論

惠东县| 岐山县| 师宗县| 安仁县| 宣汉县| 盐津县| 长子县| 巴里| 通道| 尼玛县| 泉州市| 五河县| 南皮县| 香港| 历史| 桐庐县| 辽宁省| 贺兰县| 涞源县| 商水县| 镇雄县| 鹤峰县| 禹州市| 正阳县| 安新县| 黑水县| 富裕县| 望谟县| 都江堰市| 玉林市| 东方市| 闸北区| 白玉县| 徐州市| 加查县| 长泰县| 盐池县| 海盐县| 宁明县| 高邑县| 上林县|