-
下载动画库:
npm i lottie -
在使用页面引入,注册
<script> import dropboxDxJson from "@/assets/gif/drop-box-dx.json"; // 导入动效 JSON 文件 import lottie from "lottie-web"; export default { components: { lottie, }, ..... </script> -
在html预留一个动画的位置
<template> <div class="dx-drop-static-box" ></div> </template> <style scoped> .dx-drop-static-box { position: absolute; top: -1rem; left: 0; width: 100%; height: 100%; z-index: 99; } </style> -
动画实例化
mounted() { this.lottie = lottie.loadAnimation({ container: document.querySelector(".dx-drop-static-box"), // 动画容器 renderer: "svg", // 渲染器类型,可以选择 'svg' 或 'html' loop: true, // 是否循环播放 autoplay: true, // 是否自动播放 animationData: dropboxDxJson, // JSON 文件的路径 }); }
vue项目实现动效交互---lottie动画库
来啦来啦~2024-11-26 16:37
相关推荐
小李子呢02113 小时前
前端八股Vue(5)---v-if和v-showyuki_uix3 小时前
跨域与安全:CORS、HTTPS 与浏览器安全机制用户3153247795453 小时前
React19项目中 FormEdit / FormEditModal 组件封装设计说明陆枫Larry3 小时前
Git 合并冲突实战:`git pull` 失败与 `pull.ff=only` 的那些事江南月3 小时前
让智能体边想边做:从 0 理解 ReActAgent 的工作方式YiuChauvin3 小时前
vue2中使用 AntV G6袋鱼不重3 小时前
Hermes Agent 安装与实战:从安装到与 OpenClaw 全方位对比汉秋3 小时前
iOS 自定义 UICollectionView 拼图布局 + 布局切换动画实践江南月3 小时前
让智能体学会自我改进:从 0 理解 ReflectionAgent 的迭代优化尽欢i3 小时前
前端响应式布局新宠:vw 和 clamp (),你了解吗?