Typescript property doesnt exist on type unknown with file uploader

Viewed 31

I am trying to create an upload image vue component. I am getting multiple errors from webstorm and Ive tried copying and pasting similar code with the same error. I also get the error on using .click() . The error on hover states "Property files doesnt exist on type unknown"

enter image description here

1 Answers

use it like this:

const fileInput = this.$refs.fileInput1 as HTMLInputElement

if (fileInput?.files && fileInput.files[0]){
  formData.append('image_main', fileInput.files[0])
}
Related