[英]Typescript Error: Property 'files' does not exist on type 'HTMLElement'
I wish to create an upload function for my Apps by using IONIC. 我希望使用IONIC为我的应用程序创建上传功能。
Here is my HTML code: 这是我的HTML代码:
<input ion-button block type="file" id="uploadBR">
<input ion-button block type="file" id="uploadIC">
<button ion-button block (click)="upload()">Confirm Claim Restaurant</button>
Here is my upload()
function: 这是我的
upload()
函数:
upload(){
let BR = document.getElementById('uploadBR').files[0]
let IC = document.getElementById('uploadIC').files[0]
console.log(BR)
console.log(IC)
}
In normal HTML it should work, but it doesn't work with my IONIC. 在普通的HTML中它应该可以工作,但它不适用于我的IONIC。
When building the App, it will show the error Typescript Error: Property 'files' does not exist on type 'HTMLElement'.
构建应用程序时,它将显示错误
Typescript Error: Property 'files' does not exist on type 'HTMLElement'.
Am i do it in wrong way or it has to be done in different way with typescript? 我是以错误的方式做到的,还是必须以打字稿的不同方式完成?
Thanks. 谢谢。
您需要将其转换为HTMLInputElement,因为files
是input
元素的属性
let BR = (<HTMLInputElement>document.getElementById('uploadBR')).files[0];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.