在不使用RequireJs(或任何模块加载程序)的情况下使用此脚本



我不是JavaScript开发人员,我正在努力做一个附带项目的小实验
我正在尝试在没有RequireJs的情况下使用此脚本。

https://github.com/xxmuaddib/lottie-colorify/blob/master/examples/example1/index.html

我已经尝试了一段时间并检查了StackOverflow,但我对JavaScript知之甚少。

到目前为止,我得到的是:

<html style="width: 100%; height: 100%">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.6.3/lottie.min.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<!--  <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script> -->
<script src="../../lib/umd/index.js"></script>
</head>
<body style="background-color: #ccc; margin: 0px; height: 100%; font-family: sans-serif; font-size: 10px">
<div style="width: 100%; height: 100%; background-color: #333" id="bodymovin"></div>
<script>
//requirejs(['../../lib/umd/index'], function (lc) {"
$.getJSON('https://assets6.lottiefiles.com/packages/lf20_guwqiaxe.json', function (data) {
var animData = {
wrapper: document.getElementById('bodymovin'),
animType: 'html',
loop: true,
prerender: true,
autoplay: true,
animationData: lc.flatten('#ffff00', data),
};
var anim = bodymovin.loadAnimation(animData);
});
//});
</script>
</body>
</html>

我删除了RequiredJS的CDN及其实现,并在<script>标签之间手动链接了脚本。但是现在没有定义变量lc

requirejs加载此文件的脚本https://github.com/xxmuaddib/lottie-colorify/blob/master/lib/umd/index.js所以如果你要评论这个库,只需删除它的回调返回";lc";变量抛出错误的行应该是这样的animationData:flatform('#ffff00',data(,//您已经导入了lib/umd/index.js文件,该文件具有功能

相关内容