使用elementui中el-collapse折叠面板 实现选项卡功能

实现效果:

点击左侧菜单--点谁谁变色,展示对应右侧的内容块

      <div class="data-dictionary dis">
        <!-- 左侧菜单标题-->
        <div class="data-dictionary-menu">
          <div class="tree-top">名称</div>
          <div class="tree-content">
            <el-collapse v-model="activeName"
                         accordion
                         v-for="(item,index) in dataTree"
                         :key="index">
              <div @click="menuClick(item.id)"
                   :class="activeIndex === item.id ? 'bottom-tabs-active' : ''"
                   style="line-height:40px;">{{ item.name }}</div>
            </el-collapse>
          </div>
        </div>
        <!-- 右侧内容区域---el-table表格 -->
        <div class="data-dictionary-table">
          <CustomerStage v-if="activeIndex === '1'" />
          <CustomerSource v-if="activeIndex === '2'" />
          <CustomerLevel v-if="activeIndex === '3'" />
          <CustomerIndustry v-if="activeIndex === '4'" />
          <CompanySize v-if="activeIndex === '5'" />
          <ContactType v-if="activeIndex === '6'" />
          <VendorVlass v-if="activeIndex === '7'" />
        </div>
      </div>

css

 <style lang="scss" scoped>
  .dis {
    display: flex;
  }
  .data-dictionary {
    .data-dictionary-menu {
      width: 20%;
      height: 100vh;
      margin-right: 20px;
      border: 1px solid rgb(222, 220, 220);
      border-radius: 4px;
      text-align: center;
      .bottom-tabs-active {
        // line-height: 40px;
        background-color: rgb(237, 244, 253);
      }
      .tree-top {
        color: #ffffff;
        padding: 20px 0px;
        border-radius: 4px 4px 0 0;
        background-color: rgb(34, 124, 229);
        border-bottom: 1px solid rgb(222, 220, 220);
      }
      .tree-content {
        padding: 0px 10px;
      }
    }
    .data-dictionary-table {
      width: 80%;
    }
  }
</style>

js

<script>
import CustomerStage from './CustomerStage.vue'
import CustomerSource from './CustomerSource.vue'
import CustomerLevel from './CustomerLevel.vue'
import CustomerIndustry from './CustomerIndustry.vue'
import CompanySize from './CompanySize.vue'
import ContactType from './ContactType.vue'
import VendorVlass from './VendorVlass.vue'
export default {
  components: {
    CustomerStage,
    CustomerSource,
    CustomerLevel,
    CustomerIndustry,
    CompanySize,
    ContactType,
    VendorVlass
  },
  data: function () {
    return {
      dataTree: [],
      activeIndex: '1', // 数据名称
      activeName: ''
    }
  },
  methods: {
    // 获取左侧的菜单
    getMainUnit () {
      this.$http.get(``).then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        }
        // console.log(res.data)
        this.dataTree = res.data
      })
    },
    // 点击获取分页
    menuClick (id) {
      // console.log(id, typeof id)
      this.activeIndex = id // 改变样式
      // console.log(this.activeIndex, this.activeName)
    }
  }
}
</script>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Element UI是一套基于Vue.js的组件库,其el-dialog是其的一个组件,用于实现弹窗对话框的功能。下面是关于el-dialog的使用介绍: 1. 引入Element UI库:在Vue项目,首先需要引入Element UI库。可以通过npm安装,然后在项目的入口文件引入Element UI的样式和组件。 2. 使用el-dialog组件:在需要使用弹窗对话框的地方,可以使用el-dialog组件进行布局和交互。以下是el-dialog的基本用法: ```html <template> <div> <el-button @click="showDialog">打开对话框</el-button> <el-dialog :visible.sync="dialogVisible" title="对话框标题"> <p>对话框内容</p> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取 消</el-button> <el-button type="primary" @click="dialogVisible = false">确 定</el-button> </span> </el-dialog> </div> </template> <script> export default { data() { return { dialogVisible: false }; }, methods: { showDialog() { this.dialogVisible = true; } } }; </script> ``` 在上述代码,通过点击按钮打开对话框,使用`:visible.sync`绑定`dialogVisible`变量控制对话框的显示与隐藏。`title`属性设置对话框的标题,`slot="footer"`用于自定义对话框的底部按钮。 3. 自定义对话框内容:可以在el-dialog组件内部编写自定义的对话框内容,可以是文本、表单、图片等任意HTML元素。 4. 更多配置选项:el-dialog还提供了一些其他的配置选项,如`width`设置对话框的宽度,`modal`设置是否显示遮罩层等。可以根据实际需求进行配置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值