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

124
Vistas
Inertia+Vue3, How to get the value of a ref property and pass it as route() parameter?

I need to get the value of a reference property and pass this value in the <Link :route()> parameter

My code in Component.vue

 <div class="item" v-for="item in props.user.items" :key="item.id">

<Link :href="route('user.route', {id: item.id, ll: getCurrentRef() })">Go to edit</Link>

<div>
<TextInput type="number" :id="`ll_${item.id}`" name="ll" :value="item.ll?0"
@keyup="setCurrentRef($event.target.value);" />
</div>

</div>

<input type="text" ref="element" id="element" value="XX">

<script setup>
import {ref, onMounted} from 'vue';

const element = ref(null)

const setCurrentRef = (value) => {
 element.value.value = value;
}

const getCurrentRef = () => {
 return element.value.value = value;
}

onMounted(() => {
 //alert(element.value.value)
});

I can set the value of ref element in @keyup with setCurrentRef() method normally, but I don't get the value with getCurrentRef() method

In onMounted, when I refresh the page, I see the first value of the element which is "XXX", but if you put this return "alert(item.value.value)" in a function and call it anywhere, this returns an alert. with "undefined"

In the console, the error that appears is: Uncaught (in promise) ReferenceError: value is not defined.

over 2 years ago · Carlos Garzón Colorado
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