Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

huangapple go评论66阅读模式
英文:

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)时,动画无法加载,并且控制台中会出现一些错误。我该如何解决这个问题?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

英文:

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?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

Why is my Lottie animation loading properly on localhost server, but failing to load on the deployment server?

答案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)

huangapple
  • 本文由 发表于 2023年6月13日 17:18:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76463400.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定