我正在尝试从 Canvas 中获取 dataUrl 以用作各种元素上的 css 背景图像。
但我总是收到以下错误 Uncaught TypeError: Object #<HTMLCanvasElement> has no method 'toDataUrl'
这是我的测试代码
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>
<script type="text/javascript">
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="#FF0000";
ctx.fillRect(0,0,150,75);
alert(c.toDataUrl());
</script>
</body>
</html>
它又是伪装的安全功能吗?还是我只是愚蠢...
提前致谢
最佳答案
关于javascript - HTMLCanvasElement 没有方法 'toDataUrl',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10268133/