-
下载动画库:
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
相关推荐
mCell1 天前
使用 useSearchParams 同步 URL 和查询参数mCell1 天前
前端路由详解:Hash vs History海上彼尚1 天前
无需绑卡的海外地图1024肥宅1 天前
手写 call、apply、bind 的实现科杰智能制造1 天前
纯前端html、js实现人脸检测和表情检测,可直接在浏览器使用每天吃饭的羊1 天前
组件库的有些点击事件是name-click这是如何分装deCoder-coco1 天前
个人健康管理|基于springboot+vue+个人健康管理系统(源码+数据库+文档)x***01061 天前
SpringSecurity+jwt实现权限认证功能1024肥宅1 天前
防抖(Debounce)1024肥宅1 天前
节流(Throttle)