简体   繁体   English

Visual Studio中的jQuery'文件'属性抛出错误

[英]JQuery 'files' property throwing error in visual studio

I have added the following code in my javascript file. 我在我的javascript文件中添加了以下代码。

$('#file0')[0].files[0].size

file0 is a file upload control. file0是文件上传控件。

after adding the above code, I am getting compilation error stating. 添加以上代码后,我得到了编译错误说明。

The property 'files' does not exist on value of type 'HTMLElement'. 属性“文件”在类型“ HTMLElement”的值上不存在。

But the code seems to be valid code and it works. 但是该代码似乎是有效的代码,并且可以正常工作。

Please help me to resolve the compilation error. 请帮助我解决编译错误。

在调用.files属性之前,将其强制转换为HTMLInputElement ,如下所示:

(<HTMLInputElement>$('#file0')[0]).files[0].size

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM