Vue封装组件-面板2-LjPanel2

效果图:

  使用:

        <LjPanel2
          title="这是标题"
          width="300px"
          height_content="100px"
          :showCloseBtn="true"
          @closeBtn="closeBtn"
        >
          <div v-for="item in 50" :key="item">{{ item }}</div>
        </LjPanel2>

 LjPanel2.vue:

<!--LjPanel2-->
<template>
  <div class="LjPanel2" :style="{ width: width }">
    <div class="LjPanel2_head">
      <span>{{ title }}</span>
      <span v-if="showCloseBtn" class="closeBtn" @click="closeBtn()">x</span>
    </div>
    <div class="content" :style="{ height: height_content }">
      <el-scrollbar style="height: 100%">
        <slot></slot>
      </el-scrollbar>
    </div>
  </div>
</template>

<script>
export default {
  name: "LjPanel2",
  components: {},
  props: {
    title: {
      type: String,
      default: "标题",
    },
    width: {
      type: String,
      default: "100%",
    },
    //设置此属性,让滚动条生效
    height_content: {
      type: String,
      default: "50px",
      required: true,
    },
    showCloseBtn: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {};
  },
  computed: {},
  created() {},
  mounted() {},
  filters: {},
  methods: {
    closeBtn() {
      this.$emit("closeBtn");
    },
  },
  watch: {},
};
</script>

<style lang="scss" scoped>
$primary_color: #32b6ff;

.LjPanel2 {
  border: 2px solid $primary_color;
  background-color: rgba(12, 12, 12, 0.6);
  min-width: 120px;
  color: white;
  font-size: 18px;

  .LjPanel2_head {
    border-bottom: 1px solid $primary_color;
    text-align: center;
    line-height: 40px;
    word-break: break-all;
    caret-color: transparent;

    .closeBtn {
      float: right;
      padding-right: 10px;

      &:hover {
        color: $primary_color;
        cursor: pointer;
      }
    }
  }
  .content {
    padding: 15px;
    word-break: break-all;
    ::v-deep .el-scrollbar__wrap {
      overflow-x: hidden;
    }
  }
}
</style>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值