-
下载动画库:
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
相关推荐
@atweiwei21 小时前
LangChainRust 0.33.0 发布:让 Agent 应用更容易运行、观察和评测yuki蜜语1 天前
「阴升阳降」不符合物理常识?我用一台热虹吸做了个可拆解的 3D 模型ZJPRENO1 天前
一个被身份证认证逼出来的开源项目:AI 辅助开发实战GoodStudyAndDayDayUp1 天前
请求前端页面&traefik流程AI开源软件1 天前
用MQTT跑通一台模拟设备:看懂IoT产品、物模型和告警CV-deeplearning1 天前
Chrome DevTools实战xurileidian1 天前
第 30 篇 · 边玩边学Python · 猜数字小游戏 把判断循环异常串起来前端精髓1 天前
三种方式实现 Agent 工具调用:OpenAI、LangChain 与 LangGraph国科安芯1 天前
光链路捕获的那一刻:商业激光通信终端捕获跟踪伺服与探测前端的低噪声供电一铭111991 天前
微信小程序可视化搭建实战:模板、组件与发布验收