Tipo 'HTMLFormControlsCollection' non ha proprietà 'x' e non firma indice di stringa

voti
0

Questo errore viene visualizzato quando si cerca di destrutturare un form.elementsoggetto.

// in a class

domRefs: {[key: string]: HTMLFormElement | null} = {
  myForm: null
}

onButtonClick = () => {
  console.debug(this.domRefs.myForm!.elements) // screenshot below
  const {a, b, c} = this.domRefs.myForm!.elements
}

entrare

Non voglio utilizzare il : anytipo che non emette questo errore.

È pubblicato 02/04/2018 alle 11:48
fonte dall'utente
In altre lingue...                            

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more