rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.25k stars 175 forks source link

Unable to get the value of svelte-select #600

Open exqmjmz opened 1 year ago

exqmjmz commented 1 year ago

I used svelte-select as select plugin image image This is a simplified example The input component input can get the value The value cannot be obtained after the select component is selected

<script>
  import Select from "svelte-select@5.6.0";
    import { useForm } from "svelte-use-form@2.6.2";
    const form = useForm();
  let collection = [
    { value: 1, label: "one" },
    { value: 2, label: "two" },
    { value: 3, label: "three" }
  ];
</script>

<form use:form>
<input name="test" >
<Select name="select" items={collection} />

</form>

<pre>
{JSON.stringify($form, null, " ")}
</pre>

svelte-app.zip

EddTally commented 1 year ago

@ljm000 Do you mean, if you use document.querySelector to get the svelte select component, you cannot retrieve the value from it?

avillegas commented 11 months ago

You can add a input hidden with value={justValue} and set the select with bind:justvalue