Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Los eventos de entrada de Vue Js se disparan al mismo tiempo

Así que tengo el siguiente formulario:

 <FormulateForm @submit="onSubmit"> <FormulateInput type="text" label="Total Time" name="totalTime" validation="^required" @keydown="isNumber" v-on:blur="formatDigits($event,'totalTime')" /> <FormulateInput type="text" name="restingDuration" label="Resting Duration" validation="^required" @keydown="isNumber" v-on:blur="formatDigits($event, 'restingDuration')" /> </FormulateForm>

la función de formato de dígitos simplemente formatea la entrada del número como 212 -> 2:12. El evento de desenfoque funciona bien, sin embargo, el evento de desenfoque y de teclado está ocurriendo en cada campo de entrada y deshace el formato del campo de entrada anterior cuando modifico el segundo. ¿Hay alguna manera de vincular el evento y desenfocar el evento a un campo específico en lugar de que se active con cada pulsación de tecla?

Aquí está la función de formato:

 formatDigits(event, name) { const inputVal = event.target.value; let final; if (event.target.name === name) { if (inputVal?.length > 0 && inputVal?.length <= 2) { let minutes = this.clamp(inputVal.slice(0), 0, 59); final = '0000:' + minutes; } else if (inputVal?.length > 2 && inputVal?.length <= 6) { const secondsIndex = inputVal.length - 2; const hours = this.clamp( inputVal.slice(0, secondsIndex), 0, 9999, true, 4, ); const minutes = this.clamp( inputVal.slice(secondsIndex, inputVal.length), 0, 59, ); final = hours + ':' + minutes; } else { //invalid length return; } event.target.value = final; } },

Aquí está la función de abrazadera:

 clamp(val, min, max, isHours, lengthMax) { const ret = val > max ? max : val < min ? min : val; if (isHours) { if (ret.length < lengthMax) { const zeroes = '0'.repeat(lengthMax - ret.length) + ret; return zeroes; } return ret; } return ret.toString().length % 2 === 0 ? ret : '0' + ret; },
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!