The intention of this code is to activate a child component when clicking on it within a parent Vue.
Parent Vue file:
<PackageItem
v-for="pack in packagesData"
:key="pack.id"
@click.native="selectPackageItem(pack.id, pack.humanLabel, pack.humanPrice, pack.index)"
>
Child component:
props: {
selected: Boolean
},
data () {
return {
selected: selected
}
},
How can I pass the selected
prop to a child component on click? Instead of setting it like this:
<PackageItem
:selected="true"
@click.native="selectPackageItem(pack.id, pack.humanLabel, pack.humanPrice, pack.index)"
>
This would set all items to be selected as true
, but I only want to do it on click.