gpt4 book ai didi

javascript - typescript 错误 TS2339 : Property 'webkitURL' does not exist on type 'Window'

转载 作者:太空狗 更新时间:2023-10-29 16:55:59 26 4
gpt4 key购买 nike

在使用 typescript 编译的项目上使用 Angular 2。

尝试创建 blob 图像时出现此错误:

错误 TS2339:类型“Window”上不存在属性“webkitURL”

ts代码是:

public url = window.URL ||窗口.webkitURL;
this.photo = this.url.createObjectURL( res );

最佳答案

error TS2339: Property 'webkitURL' does not exist on type 'Window'

lib.d.ts 不附带特定于浏览器的内容。但是,您可以轻松地执行 (window as any).webkitURL。这称为 type assertion .

更多

常见的 (如任何) 风格类型断言是 alm 提供的快速修复:https://basarat.gitbooks.io/alm/content/features/quickfix.html

关于javascript - typescript 错误 TS2339 : Property 'webkitURL' does not exist on type 'Window' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38802171/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com