当前位置: 首页 > ai >正文

【组件】翻牌器效果

目录

  • 效果
  • 组件代码
  • 背景素材

效果

在这里插入图片描述

组件代码

<template><divclass="card-flop":style="{height: typeof height === 'number' ? `${height}px` : height,'--box-width': typeof boxWidth === 'number' ? `${boxWidth}px` : boxWidth,'--box-height': typeof boxHeight === 'number' ? `${boxHeight}px` : boxHeight,'--color': color}"><div:class="{ 'card-flop__number': true, 'is-comma': isNotNumber(number) }"v-for="(number, index) in countArray":key="`num-${index}`"><div v-if="isNotNumber(number)" class="card-flop__number-comma"><span>{{ number }}</span></div><div v-else class="card-flop__number-box" :style="{ transform: getTransform(number, index) }"><div v-for="(item, index) in numbers" class="card-flop__number-item" :key="`item-${index}`"><span>{{ item }}</span></div></div></div><div class="card-flop__unit"><span>{{ unit }}</span></div></div>
</template><script >
export default {name: 'CardFlopCom',components: {},props: {count: {type: [String, Number],default: 0},height: {type: Number,default: 32},boxWidth: {type: Number,default: 24},boxHeight: {type: Number,default: 32},unit: {type: String,default: '条'},color: {type: String,default: '#fff'}},data() {return {numbers: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}},computed: {countArray() {// 将数字转换为带千位分隔符的字符串const formattedNumber = Number(this.count).toLocaleString()// 分割成数组,包括逗号return formattedNumber.split('')}},methods: {isNotNumber(number) {return [',', '.'].includes(number)},getTransform(number) {const offset = Number(number) * this.boxHeightreturn `translateY(-${offset}px)`}}
}
</script><style lang="scss" scoped>
.card-flop {display: flex;align-items: baseline;justify-content: center;&__number {height: var(--box-height);color: var(--color);background-size: 100% 100%;background-repeat: no-repeat;margin-right: 3px;overflow: hidden;&:not(.is-comma) {width: var(--box-width);// background-image: url('@/assets/images/screen-zhidu/card_flop_bg.png');background-image: url('~@/assets/images/screen-zhidu/card_flop_bg.png');}&.is-comma {margin-right: 2px;}&-box {transition: transform 1s ease-in-out;}&-item {width: var(--box-width);height: var(--box-height);display: flex;align-items: center;justify-content: center;span {font-weight: bold;font-size: 26px;}}}&__unit {font-size: 16px;color: rgba(225, 239, 255, 0.6);margin-left: 2px;}
}
</style>

背景素材

在这里插入图片描述

http://www.xdnf.cn/news/9503.html

相关文章:

  • More SQL(Focus Subqueries、Join)
  • 如何优化Elasticsearch的搜索性能?
  • 登高架设作业考试中常见的安全规范考点是什么?
  • DBeaver 连接 OceanBase Oracle 租户
  • react-native的token认证流程
  • AI觉醒前兆,ChatGPT o3模型存在抗拒关闭行为
  • 《吾心悔已》---李劭卓2025.5.28
  • 漫画Android:View是怎么绘制出来的?
  • MySQL数据库(一)
  • 华为OD机试真题——最佳的出牌方法(2025A卷:200分)Java/python/JavaScript/C/C++/GO最佳实现
  • 嵌入式开发学习(第二阶段 C语言笔记)
  • 电缆护层保护器的优势
  • OpenWrt 插件安装失败的常见问题和解决方法
  • sglang 部署Qwen/Qwen2.5-VL-7B-Instruct
  • JavaScript 性能优化:从入门到实战
  • 将文件夹中的未命名的文件类型或txt的文件类型改为dat类型
  • mybatis-plus实现增删改查(新手理解版)
  • 6.4.2_3最短路径问题_Floyd算法
  • 【连接器专题】案例:SD卡座规格书接触阻抗测试标准EIA-364-06B和EIA-364-23有什么区别?
  • day023-面试题总结
  • 【计算机网络】4网络层①
  • STM32学习笔记---时钟树
  • 易学探索助手-个人记录(十二)
  • 【ArcGIS Pro草履虫大师】空间地图系列
  • 数据结构之堆(topk问题、堆排序)
  • 功能测试向量是个什么概念
  • 开源架构在移动端开发中的卓越应用与深度解析
  • Java+POI+EXCEL导出柱形图
  • 小程序定制开发:从需求到落地,打造企业专属数字化入口
  • Android 13中 配置签名文件与内置相应的Apk