Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
273 views
in Technique[技术] by (71.8m points)

javascript - How can I get the value of a data with svelte-select

hello I have two select in one I have to send the selected data together with the id and the clientValue, and the second select must send only the selected string value, but I don't really understand how to do it

<script>

let chores: Chore []= [];
let types : EquipmentType[] = [];


$: choreOptions = chores.map((c:Chore) => new deviceOption(c.id,c.name));
$: typesOptions =  types.map((t:EquipmentType) => { return t.name });

 let data = undefinded

function selectionOpt(event){
 data = event.detail
}

onMount(() => {

  getChoreDevices()
  .then( chrs => {
    chores = chrs;
    console.debug(chores);
  })
  .catch(e => {
    console.error(e);
  })

  getEquipmentTypes()
  .then( ts => {
    types = ts;
    console.debug(types);
  })
  .catch( e => {
    console.error(e);
  });
  
  }
  
 </script>
 
 
 <div class="form-group">
      <label for="">Chore:</label>
      <Select items={choreOptions} on:select={selectionOption}></Select>
    </div>

    <div class="form-group">
      <label for="">Type:</label>
      <Select items={typesOptions} on:select={selectionOptType}></Select>
    </div><br>
question from:https://stackoverflow.com/questions/66057188/how-can-i-get-the-value-of-a-data-with-svelte-select

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...