-
下载动画库:
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
相关推荐
橙露6 分钟前
Webpack/Vite 打包优化:打包体积减半、速度翻倍chushiyunen10 分钟前
python中的魔术方法(双下划线)楠木68525 分钟前
从零实现一个 Vite 自动路由插件终端鹿35 分钟前
Vue2 迁移 Vue3 避坑指南程序员陆业聪40 分钟前
工程师的瓶颈,已经不是代码了毛骗导演1 小时前
@tencent-weixin/openclaw-weixin 源码ContextToken 持久化改造:实现微信自定义消息发送能力爱丽_1 小时前
Pinia 状态管理:模块化、持久化与“权限联动”落地SuperEugene1 小时前
TypeScript+Vue 实战:告别 any 滥用,统一接口 / Props / 表单类型,实现类型安全|编码语法规范篇我是永恒2 小时前
上架一个跨境工具导航网站电子羊2 小时前
Spec 编程工作流文档