Answers for "svelte else block"

6

svelte if else

{#if loaded}
    <h1>Hello World!</h1>
  {:else}
    <h1>Loading...</h1>
{/if}


example 2:
{#if status == 200}
    <h1>Hello World!</h1>
  {:else if status == 401}
    <h1>Not Authorized</h1>
  {:else}
    <h1>Don't know what happened in there</h1>
{/if}
Posted by: Guest on July-26-2021
1

svelte if block

<script>
	let user = { loggedIn: false };
	let toggle = () => user.loggedIn = !user.loggedIn;
</script>

{#if user.loggedIn}
	<button on:click={toggle}>Log out</button>
{/if}

{#if !user.loggedIn}
	<button on:click={toggle}>Log in</button>
{/if}
Posted by: Guest on August-24-2021

Browse Popular Code Answers by Language