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

188
Vistas
how can i make a readonly field when edited

I'm new to vue.js. I want username to be readonly when user wants to edit his record. But it should not be readonly when first registering. Where am I doing wrong, or what should I add ?

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Assuming you have a property (or computed, or data) which holds the information on whether the user is currently editing their profile (let's name it isEditingProfile), just provide it to input's :readonly, like so:

new Vue({
  el: '#app',
  data: () => ({
    isEditingProfile: false,
    username: ''
  })
})
<script src="https://v2.vuejs.org/js/vue.min.js"></script>
<div id="app">
  <input v-model="username" :readonly="isEditingProfile">
  
  <label>
    <input type="checkbox" v-model="isEditingProfile"> Is editing profile 
  </label>
</div>

Note: I've made isEditingProfile editable here to showcase it's working. In your app, link it to whatever logic should control it. Most probably, you need a computed for it.

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