javascript - Safari 15 在渲染画布时崩溃
问题描述
macOS、iPhone 和 iPad 上的 Safari 15 在使用画布渲染时会崩溃。有什么解决办法吗?这曾经在以前的 Safari 上工作。
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script language="javascript">
function init2() {
const canvas = document.createElement("canvas");
canvas.style.width = "800px";
canvas.style.height = "600px";
canvas.width = 1600;
canvas.height = 1200;
document.body.appendChild(canvas);
var ctx = canvas.getContext('2d');
ctx.font = '48px system-ui';
ctx.fillText('Hello World, 你好中文', 10, 50);
}
</script>
</head>
<body onload="init2()">
</body>
</html>
解决方案
最后,我的解决方案是将字体“system-ui”替换为“san-serif”,这解决了我的问题。此外,在 Safari 技术预览版和 Beta 3 中已经修复了这个错误,并计划在 2021 年 10 月晚些时候发布。
推荐阅读
- javascript -
- java - Gradle 更新时的问题
- javascript - 如何在一个域的沙盒 iframe 中的元素上挂起事件?
- javascript - 承诺问题:ReferenceError:未定义拒绝
- mysql - mysql:从一个函数创建一个表到另一个模式
- django - Django views.py 文件参数传递
- javascript - fs.exists 找不到我的 .mp3 文件(node.js 和 discord.js)
- python - r'^特定表达式$'和r'特定表达式'之间的区别
- php - 复选框要传输到数据库的值
- java - 我无法创建 groovy 项目