我有一个简单的 html 来显示我在 After Effects 中制作的动画,但是在本地加载它时无法显示动画(data.json)。但是,如果我通过 LottieFiles 上传动画并使用在我的 html 文件中生成的链接,它就可以工作。有人可以解释一下为什么我不能通过我的 data.json 而不是从生成的链接加载动画吗?
贝娄我放了我到目前为止的代码:
<head>
<!-- Meta -->
<meta charset="UTF-8">
<title>Bodymovin Demo</title>
<style>
body {
text-align: center;
}
h1 {
margin-top: 2em;
}
#bm {
width: 1000px;
margin: 0 auto;
}
</style>
</head>
<body>
<h1>Test Animation</h1>
<div id="bm"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.5.9/lottie.js"></script>
<script>
var animation = bodymovin.loadAnimation({
container: document.getElementById('bm'),
renderer: 'svg',
loop: true,
autoplay: true,
// this way works, but if i put 'data.json' which is on the same directory of this file it doesn't work
path: 'https://assets7.lottiefiles.com/packages/lf20_kxQ49M.json'
});
</script>
</body>
我还有一个指向我的“data.json”文件的链接: https ://drive.google.com/file/d/1xsikpLLQY-7FMV1_S5VelmB2_85LD-oi/view?usp=sharing