# with npm
npm install lottie-web
# with bower
bower install bodymovin
首先:安装lottile
其次:新建一个lottie.vue 页面
<template>
<div :style="style" ref="lavContainer"></div>
</template>
<script>
import lottie from 'lottie-web'
export default {
props: {
options: {
type: Object,
required: true
},
},
data() {
return {
style: {
width: this.options.width ? `${this.width}px` : '100%',
height: this.options.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 !