【发布时间】:2020-08-05 02:05:57
【问题描述】:
我正在使用 bodyworks 和 lottie 加载自定义 SVG 动画,但由于某种原因它会引发 GET 错误。该文件的路径是正确的,因为当我将其复制并粘贴到浏览器中时它可以正常加载,所以我不确定出了什么问题?
var animation = bodymovin.loadAnimation({
container: document.getElementById("animationContainer"), // the dom element that will contain the animation
renderer: 'svg',
loop: true,
autoplay: true,
path: 'data.json' // the path to the animation json
});
该文件最初位于嵌套文件夹中,但我认为这可能是一些错误的原因,所以我移动了它,但它仍然无法加载它。任何帮助将不胜感激
> bodymovin.js:1300 GET file:///G:/My%20Drive/YetiTech/YetiTechNewSite/YetiTech/The%20Fresh%20Site%20of%20Bel%20Air/data.jsonnet::ERR_FAILED
【问题讨论】:
-
由于安全原因,您的浏览器正在阻止访问本地文件。正确的做法是启动一个小型开发 http-server(通常集成在流行的代码编辑器中,或作为插件提供)。没有它,你就无法进行网络开发。
标签: javascript svg lottie bodymovin