Skip to content

Commit 95d02e3

Browse files
author
zhuzhe
committed
add lottie
1 parent 29aea1b commit 95d02e3

File tree

6 files changed

+48
-1
lines changed

6 files changed

+48
-1
lines changed

.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"presets": ["es2015", "stage-0"],
33
"plugins": [
4+
"transform-runtime",
45
"add-module-exports",
56
"transform-object-rest-spread",
67
"syntax-dynamic-import",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"extend": "^3.0.0",
1313
"lodash": "^4.17.4",
14+
"lottie-web": "^5.4.2",
1415
"moment": "^2.17.1",
1516
"vue": "^2.5.17",
1617
"weex-amui": "^0.1.1",

src/components/lottie.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<template>
2+
<div
3+
ref="lavContainer"
4+
></div>
5+
</template>
6+
7+
<script>
8+
import lottie from 'lottie-web'
9+
10+
export default {
11+
props: {
12+
options: Object,
13+
autoplay: {
14+
type: Boolean,
15+
default: true
16+
},
17+
loop: {
18+
type: [Boolean, String],
19+
default: true
20+
},
21+
src: String
22+
},
23+
24+
async mounted () {
25+
let otherOptions = {
26+
container: this.$refs.lavContainer.$el,
27+
renderer: 'svg',
28+
prerender: true,
29+
loop: this.loop !== false,
30+
autoplay: this.autoplay !== false,
31+
path: this.src
32+
}
33+
this.anim = lottie.loadAnimation(otherOptions)
34+
this.$emit('animCreated', this.anim)
35+
}
36+
}
37+
</script>

src/views/test.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
<div class="panel">
44
<text class="text">Weex 是一套简单易用的跨平台开发方案,能以 Web 的开发体验构建高性能、可扩展的原生应用。</text>
55
</div>
6+
<!-- <lottie style='width:200px;height:200px;border-width:2px;' loop=true src="local://lottie/coinpig.json" />
7+
<lottie style='width:200px;height:200px;border-width:2px;' loop=true src="local://lottie/motorcycle.json" /> -->
8+
<lottie style='width:200px;height:200px;border-width:2px;' loop=true src="https://www.lottiefiles.com/storage/datafiles/nwHJNOUoNltzK7d/data.json" />
69
</scroller>
710
</template>
811

@@ -26,4 +29,4 @@
2629
font-size: 32px;
2730
}
2831
29-
</style>
32+
</style>

web/web.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import Vue from 'vue'
22
window.Vue = Vue
33
require('weex-vue-render')
4+
Vue.component('lottie', require('@components/lottie.vue').default)

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6098,6 +6098,10 @@ loose-envify@^1.0.0:
60986098
dependencies:
60996099
js-tokens "^3.0.0 || ^4.0.0"
61006100

6101+
lottie-web@^5.4.2:
6102+
version "5.4.2"
6103+
resolved "http://192.168.200.235:8282/repository/findnpmgroup/lottie-web/-/lottie-web-5.4.2.tgz#efe727ce20170946969929b50f30bfef3ec7ae55"
6104+
61016105
loud-rejection@^1.0.0:
61026106
version "1.6.0"
61036107
resolved "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f"

0 commit comments

Comments
 (0)