el-dialog el-tabs结合样式改造

el-dialog el-tabs结合 样式改造

效果:
这里写图片描述

dialog.vue (封装好的组件)

<template>
  <div>
    <el-dialog :visible.sync="dialogVisibles" class="theme1" @close="$emit('update:show', false)">
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane :label="item.label" :name="'first'+index" v-for="(item,index) in panes" :key="index">
          <div class="el-tab-pane-box" :style="'height:'+height+'px;'">
            <slot name="pane" :data="index+1">{{item.label}}</slot>
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
  </div>
</template>

<script>

export default {
  name: 'dialogTheme',
  components: {

  },

  props: {
    panes: {
      type: Array,
      default: () => ([])
    },
    height: {
      type: Number,
      default: 300
    },
    show: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      activeName: 'first0',
      dialogVisibles: this.show
    }
  },

  created() {

  },

  mounted() {

  },

  methods: {
    handleClick(item) {
      this.$emit('tab-click', item)
    }
  },
  watch: {
    show() {
      this.dialogVisibles = this.show
    }
  }

}
</script>

common.scss

// 组件样式调整
.theme1{
    .el-dialog {
         background-color: rgba(0, 0, 0, 0);
         box-shadow: 1px 1px 3px rgba(0, 0, 0, 0);
       }
       .el-dialog__header {
         padding: 0;
       }
       .el-dialog__headerbtn {
         top: 64px;
         z-index: 9999;
         .el-dialog__close {
           color: #000;
         }
       }
       .el-dialog__body {
         padding: 0;
       }
       .el-tabs--card>.el-tabs__header .el-tabs__nav {
         border: none;
       }
       .el-tabs__header {
         margin: 0;
       }
       .el-tabs__content {
         background-color: #fff;
         padding: 20px;
       }
       .el-tabs--card>.el-tabs__header .el-tabs__item.is-active {
         border-bottom: 1px solid transparent;
         background: #fff;
       }
       .el-tabs--card>.el-tabs__header .el-tabs__item {
         border-bottom: 1px solid #a3a7af;
         border-left: 1px solid #a3a7af;
         background: #ddd;
         border-top-left-radius: 20px;
         border-top-right-radius: 20px;
         &:first-child {
           border-left: 1px solid transparent;
         }
       }
       .el-tabs__item:focus.is-active.is-focus:not(:active) {
         box-shadow: none;
         border-top-left-radius: 20px;
         border-top-right-radius: 20px;
       }
   }

组件使用:
index.vue

<template>
  <div class="app-container">
    <button class="pan-btn yellow-btn" @click="OpenDialogVisible">点击打开 Dialog</button>
    <dialog-theme :height="height" :panes="panes" @tab-click="tabClick" :show.sync="show">
      <div slot="pane" slot-scope="{data}">
        <component :is="currentComponent[data]"></component>
      </div>
    </dialog-theme>
  </div>
</template>

<script>
import One from './demo01'
import Two from './demo02'
import Three from './demo03'
import Four from './demo04'
import DialogTheme from './dialog'
export default {
  name: 'dialogUse',
  components: {
    DialogTheme,
    One,
    Two,
    Three,
    Four
  },
  data() {
    return {
      panes: [
        { label: '用户管理' },
        { label: '配置管理' },
        { label: '角色管理' },
        { label: '定时任务补偿' }
      ], // 传入tabs的名字
      height: 300, // 弹框高度
      show: false, // 弹框显示
      currentComponent: {
        1: 'One',
        2: 'Two',
        3: 'Three',
        4: 'Four'
      } // 当前tab页现实的组件,组件名对应tab窗口1,2,3。。。
    }
  },

  created() {

  },

  mounted() {

  },

  methods: {
    OpenDialogVisible() {
      this.show = true
    },
    // 点击tab切换事件
    tabClick(item) {
      console.log(item)
    }
  }

}
</script>

<style lang="scss" scoped>
</style>

特别提示:silot是可以多级传递的

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值