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

245
Visualizações
vue js how to copy value from textbox to div

i am trying to run function when button is clicked.

and text box one value should display in div

Template code:

<input v-model="textdata" type="text" class="w-full rounded">

<div class="bg-white h-10 w-full  ">{{textdata}}</div>

<button @click="getvalue" class="bg-green-800  rounded " >RECEIVE</button>

VUSJS:

<script>
import { defineComponent } from 'vue'

export default defineComponent({
  setup() {

function getvalue(){
    console.log(this.textdata)
    }

return{
    getvalue,
}

}

 
})
</script>

Right now it's showing data in console, but how can i show same data on div.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should define 2 refs and then update one of them from the other upon the click event

<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  setup() {
    const textarea = ref("");
    const text = ref("");

    function getvalue(){
      this.text = this.textarea
    }

    return{
        getvalue,
        text,
        textarea,
    }
  }

})
</script>

<template>
  <input v-model="textarea" type="text" class="w-full rounded">
  <div class="bg-white h-10 w-full">{{text}}</div>

  <button @click="getvalue" class="bg-green-800  rounded " >RECEIVE</button>
</template>
about 4 years ago · Juan Pablo Isaza Relatório
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