Home > OS >  Typescript property doesnt exist on type unknown with file uploader
Typescript property doesnt exist on type unknown with file uploader

Time:08-11

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

CodePudding user response:

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