Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
Cómo pasar todos los eventos como accesorios a un componente en svelte

Estoy creando algunos componentes personalizados en svelte y no entendía cómo pasar eventos como accesorios como on:click, on:mouseup, on:whatever, lo intenté de la siguiente manera pero no funcionó:

 // button.svelte // OnClick it's a prop but in this way, I need to pass every single event manually <div on:click={OnClick} ></div>

o

 // button.svelte // I tried even in this way but it didn't really work <div {...$$restProps} {...$$props} ></div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La jerarquía es Aplicación => Exterior => Interior

aplicación:

 <script> import Outer from './Outer.svelte'; function handleMessage(event) { alert(event.detail.text); } </script> <Outer on:message={handleMessage}/>

Exterior:

 <script> import Inner from './Inner.svelte'; </script> <Inner on:message />

Interno:

 <script> import { createEventDispatcher } from 'svelte'; const dispatch = createEventDispatcher(); function sayHello() { dispatch('message', { text: 'Hello!' }); } </script> <button on:click={sayHello}> Click to say hello </button>

Ahora, esto para mí es un evento burbujeante. Si está tratando de hacerlo de manera inversa ... no estoy tan seguro de que pueda lograrlo. Los datos se transmiten, los eventos brotan.

Cuando se trata de intentar enviar todos los eventos de una sola vez, parece haber este problema de github esbelto creado para permitir la sintaxis on:* . Lamentablemente aún no está implementado.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!