Skip to content

20210521/await ブロッククイズ #1

@myLifeAsaDog

Description

@myLifeAsaDog

テーマ

await ブロック

問題文

Svelte の特徴でもある await ブロックの書き方で、以下の内で間違っているものを一つ選んでください。

A

{#await promise}
  <p>...wait</p>
{:then number}
    <p>The number is {number}</p>
{:catch error}
    <p>{error.message}</p>
{/await}

B

{#await promise}
  <p>...wait</p>
{:catch}
    <p>error happened</p>
{/await}

C

{#await promise then number}
    <p>The number is {number}</p>
{/await}

D

{#await promise catch}
    <p>error happened</p>
{/await}

回答と解説

正解は D です!

この場合は下記のように引数を指定しなければなりません。

{#await promise catch error}
    <p>error happened</p>
{/await}

await ブロックについてはこちら
https://sveltejp.dev/docs#await

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions