vue 点击左侧列表显示右侧内容

<template>
  <div class="home">
      <div class="content">
          <div class="lunbo w">
                <el-carousel>
                    <el-carousel-item v-for="item in 4" :key="item">
                    <h3>{{ item }}</h3>
                    </el-carousel-item>
                </el-carousel>
               <div class="lis"  @mouseleave="mouseLeave">
                <div class="leftmenus">
                    <ul>
                        <li :class="{active:index == currentIndex}" v-for="(item,index) in newArrL" :key="index" @mouseover="mouseOver(index)" class="item" >
                            <span>{{item.title}}</span>
                            <span>></span>
                        </li>
                    </ul>
                </div>
                <div class="show-right" v-show="isShowRight">
                    <h1 v-for="(i,index) in site" :key="i.ud">{{i.con}}</h1>
                </div>
               </div>
          </div>
      </div>
  </div>
</template>

<script>

export default {
  name: 'Home',
  data(){
      return{
          newArrL:[
              {id:1,title:'商品'},
              {id:2,title:'手机'},
              {id:3,title:'电脑'}
          ],
          currentIndex:null,
          isShowRight:false,
          site:[
              {ud:1,con:'哈哈01'},
              {ud:2,con:'哈哈02'},
              {ud:3,con:'哈哈03'}
          ]
      }
  },
  methods:{
      mouseOver(index){
          this.currentIndex=index
          this.isShowRight=true
      },
      mouseLeave(){
          this.currentIndex=null
          this.isShowRight=false
      }
  }
}
</script>

<style lang="less" scoped>
.w{
    width: 1200px;
    margin: 0 auto;
}
.content{
    background-color: #f4f4f4;
    height: 500px;
}
  .el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 300px;
    margin: 0;
  }
  
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  /deep/.el-carousel__container {
      height: 500px !important;
    //   z-index: -1;
  }
  .lunbo{
      height: 500px;
      position: relative;
  }
  .lis{
      height: 500px;
    //   background-color: rosybrown;
      position: absolute;
      top: 0;
      left: 0;
      display: flex;
      z-index: 99;
  }
  .active{
      color: #fff;
      background-color: red;
      cursor: pointer;
  }
  .leftmenus{
      width: 200px;
      height: 500px;
      background-color: rgba(105,101,101,.6);
      opacity: .5;
      ul{
          .item{
              display: flex;
              justify-content: space-between;
              color: #fff;
              padding: 0 10px;
              line-height: 40px;
            //   background-color: salmon;
          }
      }
  }
  .show-right{
      width: 1000px;
      background-color: #fff;
      box-shadow:1px 2px 3px 3px #ccc  //四周阴影
  }
</style>

 

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值