This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
let a = 1; | |
let b = 2; | |
</script> | |
<input type="number" bind:value={a}> | |
<input type="number" bind:value={b}> | |
<p>{a} + {b} = {a + b}</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
export default () => { | |
const [a, setA] = useState(1); | |
const [b, setB] = useState(2); | |
function handleChangeA(event) { | |
setA(+event.target.value); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
let count = 0; | |
$: doubled = count * 2; | |
function handleClick() { | |
count += 1; | |
} | |
</script> | |
<button on:click={handleClick}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import LoadingIndicator from "./LoadingIndicator.svelte"; | |
let statistics = []; | |
let loading = false; | |
</script> | |
<div class="container"> | |
<h2>Statistics</h2> | |
{#if loading} | |
<LoadingIndicator /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
{#if loading} | |
<LoadingIndicator /> | |
{:else} | |
<SomeOtherComponent /> | |
{/if} | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
{loading | |
? <LoadingIndicator /> | |
: <SomeOtherComponent /> | |
} | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render(){ | |
let component; | |
if (loading) { | |
component = <LoadingIndicator /> | |
} else { | |
component = <SomeOtherComponent /> | |
} | |
return ( | |
<div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
{#each cats as { id, name }, i} | |
<li> | |
<a target="_blank" href="https://www.youtube.com/watch?v={id}"> | |
{i + 1}: {name} | |
</a> | |
</li> | |
{/each} | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render(){ | |
return ( | |
<ul> | |
{this.state.cats.map(cat => ( | |
<li> | |
<a target="_blank" href={`https://www.youtube.com/watch?v=${cat.id}`}> | |
{cat.name} | |
</a> | |
</li> | |
))} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.container { | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
} | |
</style> |
OlderNewer