封装个查询条件区域组件

有时候查询页需要变化不同的样式,先看样式

左右布局,且一行显示条件区,下图是一行形式

点击按钮展示所有选项

 

上代码

1 condition-box.vue

<template>
  <div :class="'condition-box ' + conditionClass">
    <div class="condition-l" :style="conditionLStyle">
      <slot name="conditionl"></slot>
    </div>
    <div class="condition-r" :style="conditionRStyle">
      <el-button
        class="btn-show"
        type="primary"
        icon="el-icon-edit"
        circle
        @click="showAll"
      ></el-button>
      <slot name="conditionr"></slot>
    </div>
  </div>
</template>
<script>
export default {
  name: "ConditionBox",
  props: {
    conditionHeight: {
      type: String,
      default: "50px",
    },
    conditionLStyle: {
      type: String,
      default: "",
    },
    conditionRStyle: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      conditionClass: "",
      isShowAll: false,
    };
  },
  methods: {
    showAll() {
      let _this = this;
      _this.isShowAll = !_this.isShowAll;
      if (_this.isShowAll) {
        //显示所有高度
        _this.conditionClass = ` is-show-all`;
      } else {
        //只显示一行
        _this.conditionClass = ``;
      }
    },
  },
};
</script>
<style lang="less" scoped>
.condition-box {
  display: flex;
  align-items: flex-start;
  height: 50px;
  background: chocolate;
  overflow: hidden;
  .condition-l {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    .item {
      flex: 0 0 200px;
      height: 40px;
      background: cornflowerblue;
      margin: 5px 15px 5px 0;
    }
  }
  .condition-r {
    flex: 0 0 300px;
    line-height: auto;
    display: flex;
    flex-wrap: nowrap;
    .btn-show {
    }
  }
}
.is-show-all {
  height: auto;
}
</style>

2 引用

<ConditionBox :conditionLStyle="''" :conditionRStyle="'flex:0 0 300px;'">
      <div
        slot="conditionl"
        class="item1"
        v-for="(item, index) in 20"
        :key="index"
      >
        {{ index }}-11
      </div>

      <div slot="conditionr">my condition</div>
    </ConditionBox>

有点简单,喜欢拿去!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值