Skip to content

Instantly share code, notes, and snippets.

@mindrones
Last active December 6, 2018 19:12
Show Gist options
  • Save mindrones/1226fb8e8344507f70bbc7bdf6b69527 to your computer and use it in GitHub Desktop.
Save mindrones/1226fb8e8344507f70bbc7bdf6b69527 to your computer and use it in GitHub Desktop.
Dropdown
<select on:change="doSomethingWith(event)">
<option value="noerr">Por favor escolha uma opção</option>
<option value="err500" default>500</option>
<option value="err400" default>400</option>
</select>
{#if error}
<p>{error.status}: {error.msg}</p>
{/if}
<script>
const errors = {
err400: {status:400, msg: 'Requisição inválida.'},
err500: {status: 500, msg: 'Erro Interno.'}
};
export default {
methods: {
doSomethingWith(event) {
const error = errors[event.target.value];
this.set({error});
console.log("my json:", JSON.stringify(error));
}
}
}
</script>
{
"svelte": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment