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动画使用指南 #11

Open
cookiepool opened this issue Oct 8, 2019 · 0 comments
Open

[其它]Lottie动画使用指南 #11

cookiepool opened this issue Oct 8, 2019 · 0 comments
Labels
前端相关 前端相关

Comments

@cookiepool
Copy link
Owner

cookiepool commented Oct 8, 2019

Lottie动画是爱彼迎出品的能运行在H5、Android和iOS上的特效动画,废话不多说,直接开整。

  • 注意:本文只介绍在页面引入脚本的方式,vue和react上暂时没尝试过,不过官方有教程。
    直接上代码:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style type="text/css">
  	.anima {
  		width: 300px;
  		height: 300px;
  	}
  </style>
</head>
<body>
  <div id="anima" class="anima"></div>
  <script src="./lottie.min.js"></script>
  <script>
    let elem = document.getElementById('anima');
    console.log(elem)
    let animation = lottie.loadAnimation({
      container: document.getElementById('anima'), // Required
      path: 'http://192.168.12.101/notification.json', // Required
      renderer: 'svg/canvas/html', // Required
      loop: true, // Optional
      autoplay: true, // Optional
      name: "Hello World", // Name for future reference. Optional.
    });
  </script>
</body>
</html>

这儿需要注意一下,建议在演示动画的时候去下载一个xampp来搭建一个本地服务器,把相关的文件都扔在xampp\htdocs文件夹下,然后从浏览器里面输入本地地址进入页面,不然直接打开本地文件会出现跨域报错问题,比如我现在的地址是:http://192.168.12.101/lottie.html。


这里附上官网的单页面使用教程,涉及vue和react。
Vue-Lottie
React-Lottie

@cookiepool cookiepool added the 前端相关 前端相关 label Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
前端相关 前端相关
Projects
None yet
Development

No branches or pull requests

1 participant