HTMLCanvasElement 上未解决的方法 captureStream
canvas 元素和方法 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
.
相关文章