问题描述
我在画布元素和方法 captureStream
上遇到了奇怪的情况.根据文档 HTMLCanvasElement 有一个方法 captureStream
.但是我的 Angular6 应用声称没有这样的方法.
I have weird situation with canvas element and method captureStream
. According to documentation HTMLCanvasElement has a method captureStream
. However my Angular6 app claims that there isn't such method.
所以这段代码不起作用:
So this code won't work:
let canvas: HTMLCanvasElement;
canvas = document.createElement('canvas');
let stream = canvas.captureStream(20);
它在第三行失败.
此代码运行没有任何错误:
This code runs without any error:
let canvas: any;
canvas = document.createElement('canvas');
let stream = canvas.captureStream(20);
这怎么可能?我 100% 确定 HTMLCanvasElement 有这个方法并且 document.createElement('canvas') 返回 HTMLCanvasElement.
How this is possible? I'm 100% sure that HTMLCanvasElement has this method and the document.createElement('canvas') returns HTMLCanvasElement.
推荐答案
根据 MDN,看起来 captureStream
方法仍然是一个工作草案(截至 2021 年 6 月),尽管并非所有主要浏览器都实现了它.这可能就是它还不是 HTMLCanvasElement
类型定义的一部分的原因.
According to MDN, it looks like the captureStream
method is still a working draft (as of June 2021), eventhough it is not implemented by all major browsers. That is probably why it is not yet part of the type definition for HTMLCanvasElement
.
这篇关于HTMLCanvasElement 上未解析的方法 captureStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!