当前位置:   article > 正文

前端歌谣-第壹佰零二课-关于文件嵌套的封装basic-container

前端歌谣-第壹佰零二课-关于文件嵌套的封装basic-container

前言

大家好 我是歌谣 今天继续给大家带来外部嵌套的讲解

主题数据

<template>
  <div
    :class="{'basic-container--block':block}"
    class="basic-container">
    <el-card>
      <slot/>
    </el-card>
  </div>
</template>
<script>
export default {
  name: "BasicContainer",
  props: {
    block: {
      type: Boolean,
      default: false
    }
  }
};
</script>
<style lang="scss">
.basic-container {
  padding: 8px 10px;
  border-radius: 10px;
  box-sizing: border-box;
  .el-card {
    width: 100%;
    background-color: transparent;
    .el-card__body {
      padding: 10px;
      background: #fff;
    }
  }
  &:first-child {
    padding-top: 0;
  }
  &--block {
    height: 100%;
    .el-card {
      height: 100%;
    }
  }
}
</style>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

总结

这里使用基本插槽实现的数据方式 其中的slot的数据可以作为当前的数据插入
主体的逻辑不是很复杂 但是需要你细细揣摩 ok

运行结果

在这里插入图片描述

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读