我确信我错过了一些简单的东西......我遵循了这个:https://help.rive.app/runtimes/overview/web-js 它工作得很好,直到我将 src 从 ("src: "https://cdn.rive.app/animations/vehicles.riv",") 更改为我们的服务器 (src: "https://outofourmindsstudios.com/2024/车辆.riv",)。然后它就在 iPhone 上崩溃了。我缺少什么?我仍然在 Chrome 中工作。
`<!DOCTYPE html>
<html>
<head>
<title>Rive Hello World</title>
</head>
<body>
<canvas id="canvas" width="500" height="500"></canvas>
<script src="https://unpkg.com/@rive-app/[email protected]"></script>
<script src="https://unpkg.com/rive-js"></script>
<script>
const r = new rive.Rive({
src: "https://outofourmindsstudios.com/2024/vehicles.riv",
canvas: document.getElementById("canvas"),
autoplay: true,
stateMachines: "bumpy",
onLoad: () => {
r.resizeDrawingSurfaceToCanvas();
},
});
</script>
</body>
</html>`
iPhone 会仔细执行 CORS 安全性。如果您的服务器未设置为接受来自托管 HTML 文件的源(通常是单独的域)的请求,浏览器将停止动画。
尝试模拟这一点并检查页面以检查控制台是否存在 CORS 问题。大多数时候,即使您直接应用 API 调用,也会发生这种情况。