vue實現左右兩列豎直分別滑動,且雙向關聯的選項卡(一)


先完成‘左右兩列豎直分別滑動,相互之間不存在任何關聯’的頁面樣式:

<t

 

 

emplate>
<div>
  <div class="flex-between all">
    <div class="left" id=‘left’>
      <span v-for="n in 16" :key="n">{{n}}</span>
    </div>
    <div class="right id=‘right’">
      <span v-for="m in 8" :key="m">{{m}}</span>
    </div>
  </div>
</div>
</template>
<style scoped>
.left, .right{
  overflow-y: auto;
  height: 667px;//高度是指滾動窗口的高度,必須有
}
.left{
  width: 20%;
}
.right{
  width: 80%;
}
.left span{
   background: forestgreen;
}
.right span{
   background: red;
   height: 300px;
}
</style>
在實際項目當中,這兩部分不會單獨存在,需要和上下的div(如header,footer)以及長屏幕適配,所以left, .right的高度需要被動態改變:
在mounted中:
let scrollHeight = $(window).height()-190              其中190是指header,footer等其他有.all之外的高度的固定值之和
            console.log(scrollHeight)
            document.getElementById("left").style.height= scrollHeight +"px";
            document.getElementById("right").style.height= scrollHeight +"px";


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM