-
下载动画库:
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
相关推荐
学嵌入式的小杨同学7 小时前
从零打造 Linux 终端 MP3 播放器!用 C 语言实现音乐自由weixin_425543738 小时前
TRAE CN3.3.25 构建的Electron简易DEMO应用Mr Xu_9 小时前
【Vue3 + ECharts 实战】正确使用 showLoading、resize 与 dispose 避免内存泄漏0思必得09 小时前
[Web自动化] Selenium设置相关执行文件路径雯0609~9 小时前
hiprint:实现项目部署与打印1-官网提供普通html版本不绝1919 小时前
UGUI——进阶篇~牧马~10 小时前
【记录63】electron打包vue项目之踩坑Exquisite.10 小时前
企业高性能web服务器(4)2501_9445255410 小时前
Flutter for OpenHarmony 个人理财管理App实战 - 账户详情页面计算机学姐10 小时前
基于SpringBoot的电影点评交流平台【协同过滤推荐算法+数据可视化统计】