Created with svelte.technology/repl
Last active
December 6, 2018 19:12
-
-
Save mindrones/1226fb8e8344507f70bbc7bdf6b69527 to your computer and use it in GitHub Desktop.
Dropdown
This file contains 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
<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> |
This file contains 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
{} |
This file contains 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
{ | |
"svelte": true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment