Vue封装组件-可折叠面板 LjCollapse

效果图: 

 

 使用:

      <LjCollapse
        title="这是标题"
        headColor="orange"
        width="400px"
        bgColor="rgba(41, 41, 41, 0.589)"
        :isCollapse="true"
      >
        这是内容...
      </LjCollapse>

LjCollapse.vue:

<!--LjCollapse-->
<template>
  <div class="LjCollapse" :style="{ backgroundColor: bgColor, width: width }">
    <div
      class="LjCollapseHead"
      :style="{
        color: headColor,
        borderLeftColor: headColor,
      }"
      @click="collapse = !collapse"
    >
      <span>{{ title }}</span>
      <span style="float: right">
        <i v-if="collapse" class="el-icon-arrow-down"></i>
        <i v-else class="el-icon-arrow-right"></i>
      </span>
    </div>
    <div style="margin-top: 10px; font-size: 18px" v-if="collapse">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "LjCollapse",
  components: {},
  props: {
    title: {
      type: String,
      default: "标题",
    },
    headColor: {
      type: String,
      default: "orange",
    },
    bgColor: {
      type: String,
      default: "rgba(41, 41, 41, 0.589)", //浅黑
      // default: "#253266b7",//浅蓝
    },
    width: {
      type: String,
      default: "100%",
    },
    isCollapse: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      collapse: this.isCollapse,
    };
  },
  computed: {},
  created() {},
  mounted() {},
  filters: {},
  methods: {},
  watch: {},
};
</script>

<style lang="scss" scoped>
.LjCollapse {
  color: white;
  background-color: rgba(41, 41, 41, 0.589);
  padding: 10px;

  .LjCollapseHead {
    line-height: 30px;
    border-left: 5px solid;
    font-weight: bold;
    padding-left: 10px;
    font-size: 20px;
    caret-color: transparent;
    &:hover {
      cursor: pointer;
    }
  }
}
</style>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值