Created
November 5, 2019 18:14
-
-
Save tporto/59684fbbc85f9c898f6d46fcc52cd8c9 to your computer and use it in GitHub Desktop.
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> | |
<div> | |
<button @click="status = !status">change status</button> {{ status }} | |
<br> | |
<div v-for="m in marcas"> | |
<input type="checkbox" :value="m.id" v-model="checkedNames" v-on:click="click_marca(m.id)" /> {{ m.nome }} | |
</div> | |
<ul> | |
<li v-for="m in marcas"> | |
{{ m.nome }} | |
</li> | |
</ul> | |
{{ marcas }} | |
{{ checkedNames }} | |
{{ modelos }} | |
</div> | |
</template> | |
<script> | |
import axios from 'axios'; | |
export default { | |
data() { | |
return { | |
status: false, | |
marcas: [], | |
modelos: [], | |
checkedNames: [] | |
} | |
}, | |
methods: { | |
click_marca: function(value) { | |
alert(this.checkedNames); | |
axios.get('/api/modelos/' + Array.from(this.checkedNames)).then(response => (this.modelos = response.data.data)) | |
} | |
}, | |
mounted() { | |
axios.get('/api/marcas').then(response => (this.marcas = response.data.data)) | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ao clicar no checkbox quero obter o arrary "checkedNames" no metodo, mas ele só vem atualizado após o segundo clique.