themesberg / flowbite-vue

Official Vue 3 components built for Flowbite and Tailwind CSS
https://flowbite-vue.com
MIT License
773 stars 120 forks source link

Can't give initial value to the input #184

Closed Amiko1 closed 1 year ago

Amiko1 commented 1 year ago

I'm trying to give inital v-model to the input from parent but it does not work

<script setup>
import { Input } from "flowbite-vue";
defineProps(['modelValue'])
defineEmits(['update:modelValue'])
</script>
<template>
  <Input
    class="caret-red-700 rounded-2xl py-4 text-gray-400 font-medium placeholder-gray-300 focus:border-velvet focus:outline-none focus:ring-velvet"
    placeholder="მოძებნე სასურველი კერძი"
    :value="modelValue"
    @input="$emit('update:modelValue', $event.target.value)"
  >
    <template #suffix>
      <Icon class="mb-1.5" name="tabler:search" size="20" color="#D9D9D9" />
    </template>
  </Input>
</template>

<style scoped></style>

it's my component

next if I change my reactive variable it will take value but I want do it at first rendering, as I found it's normal behavior of your Input component, now I fixed it with setTimout, can you provide me some better way?

cogor commented 1 year ago

You have an error in your component, replace :value onto :model-value