Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
Difference between 'button.disabled = true' and 'button.value.disabled = true'?

The code sample is for Vue3 composition API to handle a signup form. The intention is to disable the button after it's pressed until the singin code(omitted) gets called only once.

Why is submitButton.value used vs. just the submitButton?

setup() {

const submitButton = ref<HTMLButtonElement | null>(null);

//Form submit function
const onSubmitLogin = (values) => {

  //Disable button
  /* eslint-disable  @typescript-eslint/no-non-null-assertion */
  submitButton.value!.disabled = true; 
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

submitButton is a ref which is an object with a single property named value that has the actual element.

So this:

submitButton.disabled = true

Is a type error because the ref has no property named disabled.

Where this:

submitButton.value!.disabled = true; 

Gets the value of the ref (an HTMLButtonElement) and sets the disabled property of that button.

Read more about refs in the docs: https://vuejs.org/api/reactivity-core.html#ref


Lastly, you can avoid having to silence that warning with something like:

submitButton.value && (submitButton.value.disabled = true)

here you only assign the property if the value exists.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda