Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda