Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lottie-web在vue中使用 #4

Open
bienvenidoY opened this issue May 3, 2018 · 3 comments
Open

lottie-web在vue中使用 #4

bienvenidoY opened this issue May 3, 2018 · 3 comments

Comments

@bienvenidoY
Copy link
Owner

介绍

Lottie for Android, iOS, React Native, and Web
https://github.com/airbnb/lottie-web

用了这个库,不用设计师跟我描述动画怎么动了,AE做好甩JSON就够了。并且渲染在浏览器中可以是'svg' / 'canvas' / 'html' 三种可选值

本文仅介绍 lottie-web在vue.js中的使用,想自己动手可以参考:

面向前端的 Lottie & AE 动画手把手入门教学
https://juejin.im/post/5acda0a5f265da23741153a1

demo

https://github.com/bienvenidoY/vue-lottie

web使用

详情api使用请看lottie官网

安装依赖

npm install lottie-web
//or yarn add lottie-web

代码

<template>
  <div id="app">
    <div ref="animation"></div>
  </div>
</template>

<script>
import lottie from 'lottie-web';
import Trophy from './trophy.json'

export default {
  name: 'App',
  mounted () {
    this.anim = lottie.loadAnimation({
        container: this.$refs.animation,
        renderer: 'svg',
        loop: true,
        autoplay: true,
        animationData: Trophy,//动画json
      }
    )
  }
}
</script>

tips

@Kingbultsea
Copy link

谢谢 我直接用官方的例子 竟然报错 用你的解决了

@Kingbultsea
Copy link

其实用vue-lottie的..

@1kr
Copy link

1kr commented Sep 4, 2019

你好,想请教下,有没有遇到找不到 anim 实例的情况。
我现在weex里面使用,基于vue。使用了vue-lottie,但是一直都拿不到 anim实例,动画出不了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants