自己封装的风格化的开关卡片组件

4 篇文章 0 订阅
4 篇文章 1 订阅

效果图:
效果图
代码:

<template>
  <div class="card" :class="isOpen?type:'off'">
    <el-row style="position:relative">
      <i :class="icon" style="font-size: 40px;font-weight: 100" />
      <div style="position: absolute;top: 0;right: 0;padding-top: 10px">
        <ct-switch
          v-model="isOpen"
          :circle-color="isOpen?activeColors[type]:'#fff'"
          active-color="#FDFDFD"
          inactive-color="#8A88B7"
          active-text="ON"
          inactive-text="OFF"
        />
      </div>
    </el-row>
    <el-row style="height: 40px;position: relative">
      <span style="font-size: 16px;font-weight: 600;position: absolute;bottom: 0;left:0;letter-spacing: 1px">{{ name }}</span>
    </el-row>
  </div>
</template>

<script>
import CtSwitch from './ct-switch'
export default {
  name: 'CtCard',
  components: { CtSwitch },
  props: {
    type: {
      type: String,
      default: 'off'
    },
    icon: {
      type: String,
      default: 'el-icon-coffee-cup'
    },
    name: {
      type: String,
      default: 'taitChan'
    }
  },
  data() {
    return {
      isOpen: true,
      activeColors: { success: '#2BAA5D', danger: '#F2946D', primary: '#0077F4', warning: '#7230F9' }
    }
  }
}
</script>

<style scoped>
    .card{
      border-radius: 20px;
      width: 200px;
      height: 120px;
      margin: 0 20px 20px 0;
      display: inline-block;
      padding: 20px;
      color: white;
    }
    .success{
      background-image: linear-gradient(to bottom right, #33C8B4, #2CAD66);
    }
    .primary{
      background-color: #0082F6;
    }
    .danger{
      background-image: linear-gradient(to right, #FA7D74 , #F94E39);
    }
    .warning{
      background-color: #7A40F2;
    }
    .off{
      box-shadow: 0 0  20px rgba(138, 136, 183,0.8);
    }
</style>

开关部分(ct-switch)是由这个改的,改的比较粗糙。
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值