mirror of
https://github.com/lainbo/component-party.git
synced 2026-04-05 13:09:03 +08:00
Svelte: More idiomatic "emit to parent" (#172)
* Svelte: More idiomatic "emit to parent". * Run ~~uglier~~ prettier. * Restore functions. * Restore `on:event` after merge.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
<script>
|
||||
export let onYes;
|
||||
export let onNo;
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
</script>
|
||||
|
||||
<button on:click={onYes}> YES </button>
|
||||
<button on:click={() => dispatch("yes")}> YES </button>
|
||||
|
||||
<button on:click={onNo}> NO </button>
|
||||
<button on:click={() => dispatch("no")}> NO </button>
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
</script>
|
||||
|
||||
<p>Are you happy?</p>
|
||||
<AnswerButton onYes={onAnswerYes} onNo={onAnswerNo} />
|
||||
<AnswerButton on:yes={onAnswerYes} on:no={onAnswerNo} />
|
||||
<p style="font-size: 50px;">{isHappy ? "😀" : "😥"}</p>
|
||||
|
||||
Reference in New Issue
Block a user