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
    评论
环境配置 Node 下载地址http://nodejs.cn/ 安装文件下有一个绿色的图片交node.exe 点击运行 输入node -v进行检测是否安装成功 使用vue-cli(脚手架)搭建项目 vue-cli是vue官方提供的用域搭建基于vue+webpack_es6项目的脚手架工具 在线文档:https://github.com/vuejs/vue-cli 操作: 1.npm install -g vue-cli:全局下载工具 2.vue init webpack 项目名:下载基于webpack模板项目 3.cd 项目名:进入项目目录 4.npm install :下载项目依赖的所有模块 5.npm run dev :运行项目 6.访问项目:localhost:8080 项目目录结构 src assets:存放照片、css、js css js img components:存放组件 lib:存放模拟数据 router:配置路由 store:存放vuex vuex的安装:cd x项目目录 cnpm install vuex --save views:存放所有单页面 配置访问端口号: 根目录下有一个config文件夹,看名字就知道与配置有关,打开config目录下的index.js dev: { env: require('./dev.env'), port: 8092, autoOpenBrowser: true, assetsSubDirectory: 'static', assetsPublicPath: '/', proxyTable: {}, } 项目目录下:https://blog.csdn.net/weixin_39378691/article/details/83784403 1.安装elementUI:cd进入项目根目录,npm i element-ui -S 2.引入elementUI组件(main.js文件中) import Element from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' Vue.use(Element, { size: 'small' }) 项目目录下:https://blog.csdn.net/weixin_41432849/article/details/81988058 1.安装jquery:cd进入项目根目录, npm install jquery --save 2.在项目 build 里的webpack.base.conf.js 里加载webpack文件,注意,要放在配置文件第一行; const webpack = require('webpack') 3.在module.exports的最后加入 , plugins:[ new webpack.ProvidePlugin({ $:"jquery", jQuery:"jquery", jquery:"jquery", "window.jQuery":"jquery" }) ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值