vue2使用Lottie

文章目录

    • 学习链接
    • 1.安装依赖
    • 2.创建lottie组件
    • 3.在相对应的页面应用
    • 4.相关data.json
    • 5.测试效果

学习链接

原文链接:lottie在vue中的使用

lottie官网:https://lottiefiles.com/

1.安装依赖

npm install lottie-web

2.创建lottie组件

<template>
  <div :style="style" ref="lavContainer"></div>
</template>

<script>
import lottie from 'lottie-web';

export default {
  props: {
    options: {
      type: Object,
      required: true
    },
    height: Number,
    width: Number,
  },

  data () {
    return {
      style: {
        width: this.width ? `${this.width}px` : '100%',
        height: this.height ? `${this.height}px` : '100%',
        overflow: 'hidden',
        margin: '0 auto'
      }
    }
  },

  mounted () {
    this.anim = lottie.loadAnimation({
        container: this.$refs.lavContainer,
        renderer: 'svg',
        loop: this.options.loop !== false,
        autoplay: this.options.autoplay !== false,
        animationData: this.options.animationData,
        rendererSettings: this.options.rendererSettings
      }
    );
    this.$emit('animCreated', this.anim)
  }
}
</script>

3.在相对应的页面应用

<!--
 * @Author: menxiaojin
 * @Date: 2023-02-11 17:16:08
 * @LastEditors: menxiaojin
 * @LastEditTime: 2023-11-02 14:03:41
-->

<template>
    <div class="out_box" style="height:2000px">
        <div class="lottie">
            <lottie :options="defaultOptions" :height="500" :width="500" v-on:animCreated="handleAnimation"/>
        </div>

    </div>
</template>

<script type="text/ecmascript-6">
import lottie from './lottie.vue';
import * as animationData  from './data1.json';
    export default {
        components:{
            lottie
        },

        data(){
            return {
                defaultOptions: {animationData: animationData.default},
                animationSpeed: 1

            }
        },
        methods:{
            handleAnimation: function (anim) {
                this.anim = anim;
            },
        },
        //调用方法
        mounted() {

        }
    }
</script>

<style lang="scss" scoped>

.lottie{
    width: 1000px;
    height: 700px;
    border:1px solid #ff0000;
    position: fixed;
    top:0px;
    right:50px;
}

</style>

4.相关data.json

{"v":"5.6.10","fr":30,"ip":0,"op":121,"w":76,"h":65,"nm":"预合成 1","ddd":0,"assets":[{"id":"image_0","w":76,"h":65,"u":"","p":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEwAAABBCAYAAAB7CUL1AAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAApklEQVR4nO3QQQ3AIADAQIYIhMy/t2GBvsiSOwVNn7Heb3Bs3g74G8MiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDog3kpQHJBodWGwAAAABJRU5ErkJggg==","e":1},{"id":"image_1","w":76,"h":65,"u":"","p":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEwAAABBCAYAAAB7CUL1AAAACXBIWXMAAAABAAAAAQBPJcTWAAAAJHpUWHRDcmVhdG9yAAAImXNMyU9KVXBMK0ktUnBNS0tNLikGAEF6Bs5qehXFAAAApklEQVR4nO3QQQ3AIADAQIYIhMy/t2GBvsiSOwVNn7Heb3Bs3g74G8MiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDIsMiwyLDog3kpQHJBodWGwAAAABJRU5ErkJggg==","e":1}],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"形状图层 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":0,"s":[17.83,5.078,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":25.946,"s":[61.777,5.078,0],"to":[3.034,0,0],"ti":[0,-3.034,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":31.042,"s":[67.27,10.571,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":54.904,"s":[60.403,50.398,0],"to":[0,3.034,0],"ti":[3.034,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":59.999,"s":[54.91,55.891,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":85.946,"s":[10.964,55.891,0],"to":[-3.034,0,0],"ti":[0,3.034,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":91.042,"s":[5.47,50.398,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":114.904,"s":[12.337,10.571,0],"to":[0,-3.034,0],"ti":[-3.034,0,0]},{"t":120,"s":[17.83,5.078,0]}],"ix":2},"a":{"a":0,"k":[0.781,23.375,0],"ix":1},"s":{"a":0,"k":[20,100,100],"ix":6}},"ao":1,"ef":[{"ty":5,"nm":"残影","np":7,"mn":"ADBE Echo","ix":1,"en":1,"ef":[{"ty":0,"nm":"残影时间(秒)","mn":"ADBE Echo-0001","ix":1,"v":{"a":0,"k":-0.003,"ix":1}},{"ty":0,"nm":"残影数量","mn":"ADBE Echo-0002","ix":2,"v":{"a":0,"k":160,"ix":2}},{"ty":0,"nm":"起始强度","mn":"ADBE Echo-0003","ix":3,"v":{"a":0,"k":1,"ix":3}},{"ty":0,"nm":"衰减","mn":"ADBE Echo-0004","ix":4,"v":{"a":0,"k":0.94,"ix":4}},{"ty":7,"nm":"残影运算符","mn":"ADBE Echo-0005","ix":5,"v":{"a":0,"k":2,"ix":5}}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[6.031,-0.625],[-6.031,-0.625],[-6.031,0.625],[6.031,0.625]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.337254901961,0.854901960784,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0.781,23.375],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":210,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":2,"nm":"矩形 551 拷贝","refId":"image_0","sr":1,"ks":{"o":{"a":0,"k":70.196,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33.37,55.609,0],"ix":2},"a":{"a":0,"k":[33.37,55.609,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"a","pt":{"a":0,"k":{"i":[[-3.034,0],[0,0],[0,-3.034],[0,0],[3.034,0],[0,0],[0,3.034],[0,0]],"o":[[0,0],[3.034,0],[0,0],[0,3.034],[0,0],[-3.034,0],[0,0],[0,-3.034]],"v":[[17.83,5.078],[61.777,5.078],[67.27,10.571],[60.403,50.398],[54.91,55.891],[10.964,55.891],[5.47,50.398],[12.337,10.571]],"c":true},"ix":1},"o":{"a":0,"k":100,"ix":3},"x":{"a":0,"k":0,"ix":4},"nm":"蒙版 1"}],"sy":[{"c":{"a":0,"k":[0,0.607245802879,0.919844090939,1],"ix":5},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[22]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":30,"s":[80]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":60,"s":[22]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":90,"s":[80]},{"t":120,"s":[20]}],"ix":2},"s":{"a":0,"k":13,"ix":11},"r":{"a":0,"k":50,"ix":12},"sr":{"a":0,"k":1,"ix":9},"ch":{"a":0,"k":0,"ix":10},"bm":{"a":0,"k":1,"ix":1},"no":{"a":0,"k":0,"ix":3},"j":{"a":0,"k":0,"ix":13},"ty":4,"nm":"内发光"},{"c":{"a":0,"k":[0,0.732358157635,1,1],"ix":2},"s":{"a":0,"k":1,"ix":3},"ty":0,"nm":"描边"}],"ip":0,"op":210,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":2,"nm":"矩形 551","refId":"image_1","sr":1,"ks":{"o":{"a":0,"k":40,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[38,32.5,0],"ix":2},"a":{"a":0,"k":[38,32.5,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"a","pt":{"a":0,"k":{"i":[[-3.034,0],[0,0],[0,-3.034],[0,0],[3.034,0],[0,0],[0,3.034],[0,0]],"o":[[0,0],[3.034,0],[0,0],[0,3.034],[0,0],[-3.034,0],[0,0],[0,-3.034]],"v":[[21.313,8.561],[65.26,8.561],[70.753,14.054],[63.887,53.881],[58.393,59.374],[14.447,59.374],[8.953,53.881],[15.82,14.054]],"c":true},"ix":1},"o":{"a":0,"k":100,"ix":3},"x":{"a":0,"k":0,"ix":4},"nm":"蒙版 1"}],"sy":[{"c":{"a":0,"k":[0,0.607245802879,0.919844090939,1],"ix":5},"o":{"a":0,"k":22,"ix":2},"s":{"a":0,"k":9,"ix":11},"r":{"a":0,"k":50,"ix":12},"sr":{"a":0,"k":1,"ix":9},"ch":{"a":0,"k":0,"ix":10},"bm":{"a":0,"k":1,"ix":1},"no":{"a":0,"k":0,"ix":3},"j":{"a":0,"k":0,"ix":13},"ty":4,"nm":"内发光"},{"c":{"a":0,"k":[0,0.607245802879,0.919844090939,1],"ix":2},"s":{"a":0,"k":1,"ix":3},"ty":0,"nm":"描边"}],"ip":0,"op":210,"st":0,"bm":0}],"markers":[]}

5.测试效果

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/316097.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

C++力扣题目513找树左下角的值

给定一个二叉树的 根节点 root&#xff0c;请找出该二叉树的 最底层 最左边 节点的值。 假设二叉树中至少有一个节点。 示例 1: 输入: root [2,1,3] 输出: 1示例 2: 输入: [1,2,3,4,null,5,6,null,null,7] 输出: 7 思路 本题要找出树的最后一行的最左边的值。此时大家应该想…

poi解析word取参数方法${参数名}获取参数异常处理(2024-01-12)

poi 读取word模板&#xff0c;确保 ${参数名} 在一个XWPFRun XWPFDocument读取word模板&#xff0c;经常遇到 ${参数名} 没有被识别在一个XWPFRun中&#xff0c;导致参数解析异常如法实现参数替换。 这里只是介绍word模板参数解析问题&#xff0c;让word格式如何转换为可以正常…

[易语言]易语言部署yolox的onnx模型

【官方框架地址】 https://github.com/Megvii-BaseDetection/YOLOX 【算法介绍】 YOLOX是YOLO系列目标检测算法的进一步演变和优化。它由Megvii Technology的研究团队开发&#xff0c;是一个高性能、可扩展的对象检测器。YOLOX在保留快速处理速度的同时&#xff0c;通过引入一…

【工业物联网】现代企业环境中的DCS(分布式控制系统)和SCADA(站点控制和数据采集)...

快答案&#xff1a; SCADA和DCS作为单独的系统开始&#xff0c;但一起成长。今天的带宽如此广泛&#xff0c;不需要在每个节点进行本地化。 SCADA和DCS&#xff1a;如果您参与管理企业级网络&#xff0c;您可能已经听说过这些术语。本文将阐明两种技术之间的区别。请注意&#…

2024 年 8 款最好的PDF阅读和编辑软件

写出好的内容本身就是一门艺术。写作中的错误会让你看起来粗心大意或无能为力——这两种情况都不利于你的职业形象。没有任何软件能够取代现实生活中可以指出您写作错误的编辑器。幸运的是&#xff0c;有些软件已经接近并仍在改进它们的服务以帮助您清理工作。 编辑PDF很昂贵&…

《C语言学习》---郝斌版---笔记

简介 学习计算机&#xff0c;离不开C语言的学习&#xff0c;而C语言学习过程中的视频课教程&#xff0c;目前来说&#xff0c;如果郝斌老师的C语言排第二&#xff0c;没有人敢排第一 郝斌老师的C语言教程&#xff0c;通俗易懂&#xff0c;引人发思&#xff0c;特别适合新手入门…

jmeter和meterSphere如何使用第三方jar包

工具引用jar包语言都是beanshell 问题起因&#xff1a;metersphere 接口自动化实现过程中&#xff0c;如何实现字符串加密且加密方法依赖第三方库&#xff1b; 使用语言&#xff1a;beanshell脚本语言&#xff0c;java语言 使用工具&#xff1a;idea jmeter metersphere 1.首…

2024年甘肃省职业院校技能大赛信息安全管理与评估 样题一 模块一

竞赛需要完成三个阶段的任务&#xff0c;分别完成三个模块&#xff0c;总分共计 1000分。三个模块内容和分值分别是&#xff1a; 1.第一阶段&#xff1a;模块一 网络平台搭建与设备安全防护&#xff08;180 分钟&#xff0c;300 分&#xff09;。 2.第二阶段&#xff1a;模块二…

大小鼠”专项”训练实验跑台—ZL-013小动物实验跑步机

运动疲劳的研究一直备受研究学者的关注&#xff0c;运动性疲劳动物模型也已经成为运动性疲劳研究的重要途径。运动性疲劳与一般的疲劳不同&#xff0c;其是在运动过程中发生的一种疲劳症候&#xff0c;不同的运动方式对疲劳产生的程度不同&#xff0c;对动物机体产生的影响也大…

【MyBatis】动态SQL

文章目录 前言增加操作\<trim>标签查询操作\<where>标签修改操作\<set>标签删除操作\<foreach>标签\<include>标签 前言 动态 SQL 是 MyBatis 的强大特性之一。如果你使用过 JDBC 或其它类似的框架&#xff0c;你应该能理解根据不同条件拼接 SQ…

云原⽣组件Nacos新型红队手法研究

组件简介 Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service的首字母简称&#xff0c;一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。 Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集&#xff0c;帮助您快…

C++代码重用:继承与组合的比较

目录 一、简介 继承 组合 二、继承 三、组合 四、案例说明 4.1一个电子商务系统 4.1.1继承方式 在上述代码中&#xff0c;Order类继承自User类。通过继承&#xff0c;Order类获得了User类的成员函数和成员变量&#xff0c;并且可以添加自己的特性。我们重写了displayI…

java进阶||jdk进阶之循环

从18年学java到现在除了各种各样的数据类型和集合烧不了要遍历这些变量, for循环这时就少不了啦(当然还有8后引入的神器泛型) 先来看一段精髓业务代码, 使用了多个新特性当然也少不了循环和分支判断 代码较长解析在后面 private CommonPage<List<Object>> handle…

NX二次开发PK获取对象类型

PK_ENTITY_ask_class(),获取对象类型建议用这个函数&#xff0c;比较通用&#xff0c;包含所有对象类型&#xff0c;可以替代UF_MODL_ask_edge_type(),UF_MODL_ask_body_type(),UF_MODL_ask_face_type()等函数 PK_ENTITY_t entity; PK_CLASS_t PK_TYPE; PK_ENTITY_ask_class(e…

ubuntu 22 搭建git服务

第一步&#xff0c;安装git&#xff1a; sudo apt-get install git 创建用户信息 git config --global user.name soft 第二步&#xff0c;创建一个git用户&#xff0c;用来运行git服务&#xff1a; sudo adduser git 创建git仓库的存储目录、更改文件目录属主为代码仓库…

观测云产品更新 | 日志、场景仪表板、监控器等

观测云更新 用户访问监测 &#xff08;RUM &#xff09; 公网 Dataway 支持 ip 转换成地理位置信息。 日志 > 查看器详情页 1、新增 BPF 网络日志采集及日志详情页&#xff0c;支持 Json 格式转化&#xff1b; 2、上述 1 中的日志详情页中新增可读的展示模式&#xff0c…

爬虫—响应页面乱码问题解决方法

爬虫—响应页面乱码问题解决方法 案例&#xff1a;腾牛网图片抓取 源代码如下&#xff1a; import requestsurl https://www.qqtn.com/wm/meinvtp_1.html headers {user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) …

牛客周赛 Round 1 解题报告 | 珂学家 | 分类计数 + 同余DP

前言 生于生时&#xff0c;亡于亡刻。遵从自心&#xff0c;尽人之事。 整体评价 终于等来了侧重面试的比赛&#xff0c;而且题量刚刚好&#xff0c;不超纲&#xff0c;不涉及算法竞赛。 第一场的比赛&#xff0c;感觉题目出的比较典&#xff0c;A是简单模拟&#xff0c;B则是…

springcloud sleuth分布式请求链路跟踪

简介 在微服务框架中&#xff0c;一个由客户端发起的请求在后端系统中会经过多个不同的的服务节点调用来协同产生最后的请求结果&#xff0c;每一个前段请求都会形成一条复杂的分布式服务调用链路&#xff0c;链路中的任何一环出现高延时或错误都会引起整个请求最后的失败. S…

【深度学习每日小知识】Logistic Loss 逻辑回归

逻辑回归的损失函数 线性回归的损失函数是平方损失。逻辑回归的损失函数是对数损失&#xff0c;定义如下&#xff1a; L o g L o s s ∑ ( x , y ) ∈ D − y log ⁡ ( y ′ ) − ( 1 − y ) log ⁡ ( 1 − y ′ ) LogLoss\sum_{(x,y)\in D}-y\log(y)-(1-y)\log(1-y) LogLoss…