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

225
Vistas
Return a value from a function and display it in the template [ VUE JS ]

I have a simple problem regarding returning a value from a function and displaying it inside the template tag in Vue js. Inside the function, I got the value of color but when I display it in the template I go empty string, my question is how I can update the color value in the function and over right it with the function value?

<script setup>
  import {ref, watch} from 'vue';
  import { ColorPicker } from 'vue-color-kit';
  import 'vue-color-kit/dist/vue-color-kit.css'

  let color = ref('');
  let suckerCanvas = ref(null);
  let suckerArea = ref([]);
  let isSucking = ref(false);

  
  const changeColor = (color) => {
    const { r, g, b, a } = color.rgba;
    console.log(r,g,b,a + " RGBA VALUE");
    color.value =  `rgba(${r}, ${g}, ${b}, ${a})`;
    console.log(color + " COLOR VALUE");
  } 


  console.log(color.value);

</script>

<template>

<div class="row">
    <div class="col-md-4">
        <color-picker
            theme="dark"
            :color="color"
            :sucker-hide="false"
            :sucker-canvas="suckerCanvas"
            :sucker-area="suckerArea"
            @changeColor="changeColor"
            @openSucker="openSucker"
        />
    </div>
    <div class="col-md-4"></div>
    <div :style="{background: suckerCanvas}" class="col-md-4"></div>
    <div :key="color">{{'The color is + ' + color}}</div>
</div>
</template>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

<template>

<div class="row">
    <div class="col-md-4">
        <color-picker
            theme="dark"
            :color="color.value"
            :sucker-hide="false"
            :sucker-canvas="suckerCanvas"
            :sucker-area="suckerArea"
            @changeColor="changeColor"
            @openSucker="openSucker"
        />
    </div>
    <div class="col-md-4"></div>
    <div :style="{background: suckerCanvas}" class="col-md-4"></div>
    <div :key="color">{{'The color is + ' + color}}</div>
</div>
</template>

Change your template as I changed above

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