在普通h5中使用Bodymovin和Lottie网上的教程有不少,导出data.json后引入lottie.js就能够了javascript
尝试在vue中使用时,参考https://github.com/chenqingspring/vue-lottievue
不知道其余人使用怎样,本身直接所有拷贝会出错,找不到lottie.vue的错,及数据上的错误,一样会报错的话能够尝试下。java
如下为本身修改了一点的使用方法git
1.npm install --save vue-lottie
github
2.官网代码修改如下两处:spring
为:npm
代码以下:json
<template> <div id="app"> <lottie :options="defaultOptions" :height="400" :width="400" v-on:animCreated="handleAnimation"/> </div> </template> <script> import Lottie from 'vue-lottie'; import * as animationData from './assets/data.json'; export default { name: 'app', components: { 'lottie': Lottie }, data() { return { defaultOptions: {animationData: animationData.default}, } }, methods: { handleAnimation: function (anim) { this.anim = anim; } } } </script>