-
下载动画库:
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
相关推荐
小飞侠在吗3 小时前
vue propsDsirNg4 小时前
页面栈溢出问题修复总结小徐_23334 小时前
uni-app 也能远程调试?使用 PageSpy 打开调试的新大门!大怪v4 小时前
【Virtual World 03】上帝之手用户841794814565 小时前
vxe-gantt 甘特图实现产品进度列表,自定义任务条样式和提示信息别叫我->学废了->lol在线等6 小时前
演示 hasattr 和 ** 解包操作符霍夫曼6 小时前
UTC时间与本地时间转换问题VX:Fegn08957 小时前
计算机毕业设计|基于Java人力资源管理系统(源码+数据库+文档)DARLING Zero two♡7 小时前
浏览器里跑 AI 语音转写?Whisper Web + cpolar让本地服务跑遍全网Lovely Ruby7 小时前
前端er Go-Frame 的学习笔记:实现 to-do 功能(三),用 docker 封装成镜像,并且同时启动前后端数据库服务