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

vue.js 實(shí)現(xiàn)點(diǎn)擊展開(kāi)收起動(dòng)畫(huà)效果

 更新時(shí)間:2018年07月07日 09:45:34   作者:是漁不是魚(yú)  
這篇文章主要介紹了vue.js 實(shí)現(xiàn)點(diǎn)擊展開(kāi)收起動(dòng)畫(huà)效果,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

最近公司項(xiàng)目加了個(gè)頁(yè)面,其中要求是這樣的,點(diǎn)擊對(duì)應(yīng)列表,展開(kāi)和收起,其實(shí)就是顯示和隱藏內(nèi)容部分;說(shuō)來(lái)慚愧,我花了半天時(shí)間才搞出來(lái)(自黑一下~),接下來(lái)分享給大家,先上效果圖:

vue頁(yè)面:

<template>
  <div class="dealRecord-wrap">
    <div class="title-contant" v-for="(item,index) in items " >

      <div class="title" @click="showHide(index)">

        <h3>2018年0{{index+6}}月</h3>

        <div class="number">800筆<i></i></div>

      </div>

      <div class="contant">

        <ul>

          <li v-for="i in item.allNumber">
            {{index+6}}
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
export default{
  data(){
    return{
      items:[
        {v:'qqq',allNumber:1},

        {v:'aaa',allNumber:2},

        {v:'qqq',allNumber:3},

      ],
    }
  },
  created(){
    document.body.style.backgroundColor = '#f6f6f6';
  },

  mounted(){

    for(var i=0;i<3;i++){  //這里取值自后臺(tái)返回的長(zhǎng)度,設(shè)置頁(yè)面渲染完成后是否展開(kāi),此處不展開(kāi)

      document.getElementsByClassName('contant')[i].style.height = '0px';

    }

  },

  components:{

  },

  methods:{

    showHide(index){  //點(diǎn)擊展開(kāi)收起

      let contant = document.getElementsByClassName('contant')[index];  //這里我們通過(guò)參數(shù)index來(lái)讓瀏覽器判斷你點(diǎn)擊的是哪一個(gè)列表  

      let height = contant.getBoundingClientRect().height;  //獲取頁(yè)面元素的當(dāng)前高度

      document.getElementsByTagName('i')[index].style.transform = !!height?'rotateX(0deg)':'rotateX(180deg)';

      if (!!height) {

      contant.style.height = height + 'px';

      let f = document.body.offsetHeight; //強(qiáng)制相應(yīng)dom重繪,使最新的樣式得到應(yīng)用

      contant.style.height = '0px';

      } else {

      contant.style.height = 'auto';

      height = contant.getBoundingClientRect().height;

      contant.style.height = '0';

      let f = document.body.offsetHeight;

      contant.style.height = height + 'px';

      }
    }
  },

  beforeDestroy(){
    document.body.style.backgroundColor = '#fff';
  }
}
</script>
<style type="text/scss" lang="scss" scoped>
.dealRecord-wrap{margin-bottom: 100px;

  .title-contant{overflow: hidden;  /* 這個(gè)是重點(diǎn) */

    .title{height: 84px;padding: 0 24px;border-bottom: 1px solid #eaeaea;/*px*/

      h3{height: 84px;font-size: 28px;color: #333;display: flex;align-items: center;float: left;;margin-left: 10px;}

      .number{height: 84px;font-size: 24px;color: #666;display: flex;align-items: center;float: right;}

      .number i{display: inline-block;width: 23px;height: 13px;background: url('../../assets/images/icon_dropup@2x.png');background-repeat: no-repeat;background-size: 23px 13px;background-position: right 6px center;padding-right: 35px;display: flex;align-items: center; float: right;transform:rotateX(0deg);}

    }

    .contant{background: #fff;transition: height 1s;  /* 這個(gè)也是重點(diǎn) */

      ul li{padding: 0 24px;height: 142px;display: flex;align-items: center;}

      ul li:not(:last-child){border-bottom: 1px solid #f6f6f6;/*px*/}
    }
  }
}
</style> 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。 

相關(guān)文章

最新評(píng)論

铜山县| 阿鲁科尔沁旗| 汉寿县| 浙江省| 景洪市| 仁布县| 福清市| 屏东市| 贵阳市| 杭锦旗| 怀远县| 绥江县| 若尔盖县| 和顺县| 北流市| 隆安县| 前郭尔| 肇源县| 徐州市| 余干县| 苍南县| 安徽省| 西丰县| 容城县| 巫溪县| 枝江市| 金秀| 武胜县| 胶州市| 丰镇市| 南充市| 九江县| 天水市| 连云港市| 吴忠市| 闽清县| 衡阳市| 新晃| 浦城县| 西昌市| 彩票|