需求实战一
样式展示

代码展示
<template>
<transition name="fade-in" appear>
<ARow v-if="show">
<ACol>
<div class="info-card">
<div class="info-title">
数据总和
div>
<div class="info-value">
100
div>
div>
ACol>
ARow>
transition>
template>
<script setup lang="ts">
import { ref } from 'vue';
const show = ref(false);
// 在需要的时候触发过渡效果
setTimeout(() => {
show.value = true;
}, 1000);
script>
<style scoped>
.fade-in-enter-active {
animation: fade-in 1s;
}
@keyframes fade-in {
from {
opacity: 0;
transform: translateX(-100px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.info-card {
width: 318px;
height: 116px;
background-color: #bebebe;
box-shadow: 0px 2px 10px 1px rgba(23,179,163,0.07);
border-radius: 4px;
}
.info-title {
font-size: 18px;
font-family: Microsoft YaHei;
font-weight: 400;
color: #333333;
line-height: 21px;
padding: 20px 0 20px 30px;
}
.info-value {
font-size: 36px;
font-family: Microsoft YaHei;
font-weight: bold;
color: #333333;
line-height: 21px;
padding: 0 0 0 30px;
}
style>
代码解读
这段代码是一个Vue组件,实现了一个渐入效果的过渡动画。下面是对代码的解读:
1. 标签中定义了组件的模板结构。
2.
3.
4. 是一个信息卡片的容器。
5. 显示信息的标题。
6. 显示信息的数值。
7. v-if="show" 表示只有当 show 的值为 true 时,才会渲染
8.