-
下载动画库:
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
相关推荐
search78 小时前
前端设计:CRG 3--CDC error治金的blog8 小时前
vben-admin和vite,ant-design-vue的结合的联系利刃大大9 小时前
【Vue】Vue2 和 Vue3 的区别荔枝一杯酸牛奶10 小时前
HTML 表单与表格布局实战:两个经典作业案例详解Charlie_lll10 小时前
学习Three.js–纹理贴图(Texture)yuguo.im10 小时前
我开源了一个 GrapesJS 插件安且惜10 小时前
带弹窗的页面--以表格形式展示GISer_Jing12 小时前
AI驱动营销:业务技术栈实战(From AIGC,待总结)GIS之路13 小时前
GDAL 实现影像裁剪AGMTI13 小时前
webSock动态注册消息回调函数功能实现