Created
December 9, 2019 00:03
-
-
Save mendesrl/b24e992b6380163ca5dab494b31cde69 to your computer and use it in GitHub Desktop.
Select
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
<template> | |
<Painel titulo="Resumo" roxo> | |
<select v-model="selected"> | |
<option v-for="option in produtos" | |
:key="option.preco" | |
v-bind:value="option.value"> | |
{{ option.nome }} | |
</option> | |
</select> | |
<span>Selecionado: {{ selected }}</span> | |
</Painel> | |
</template> | |
<script> | |
export default { | |
watch: { | |
selected(valor1, valor2) | |
{ | |
console.log('Antes era:', valor2) | |
console.log('Agora é:', valor1) | |
} | |
}, | |
data() { | |
return { | |
selected: 1, | |
produtos: [ | |
{ nome: 'Produto 1', quantidade: 7, preco: 14.55, value: 1 }, | |
{ nome: 'Produto 2', quantidade: 10, preco: 22.99, value: 2}, | |
{ nome: 'Produto 3', quantidade: 1, preco: 43.18, value: 3 }, | |
] | |
} | |
} | |
} | |
</script> | |
<style> | |
table { | |
width: 100%; | |
} | |
td { | |
border-top: 1px solid #EEE; | |
width: 33%; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment