英文:
Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?
问题
问题是所有的 Lottie 动画都会在我的本地主机服务器上加载,但一旦部署了Web应用程序,动画就不会加载,控制台会出现一些错误。动画文件是 .json 文件。我的项目是Next.js React 项目。
Lottie链接: https://lottiefiles.com/
但是当我打开我的部署服务器(即Vercel)时,动画无法加载,并且控制台中会出现一些错误。我该如何解决这个问题?
英文:
So the problem is all the Lottie animations will load on my local host server, but once the web app is deployed the animation doesnt load and some error comes into the console. The animation files are .json file . My project is next js react project.
Link to lottie: https://lottiefiles.com/
But when i open my deployment server (which is vercel) the animation fails to load and there are some errors in the console. How do i fix this issue?
答案1
得分: 1
你正在尝试在Vercel上进行测试,但似乎出现了一些问题,请查看此GitHub问题并发表评论 https://github.com/vercel/next.js/issues/42801#issuecomment-1317671110,其中一个解决方案建议禁用swcMinify
// next.config.js
module.exports = {
swcMinify: false,
}
英文:
You are trying it on vercel there is some issue with that please check this github issue and comment https://github.com/vercel/next.js/issues/42801#issuecomment-1317671110, one solution suggest to disable swcMinify
// next.config.js
module.exports = {
swcMinify: false,
}
答案2
得分: 0
你可以尝试使用以下代码对你的animationData进行JSON字符串化:
JSON.stringify(animationData)
英文:
Wherever you pass your animationData, could you try JSON.stringifying it
JSON.stringify(animationData)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论