Created
June 30, 2020 05:27
-
-
Save codemonkey76/07b9541ab612126f6db6f1eb1da00d50 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> | |
<div v-for="option in options"> | |
<div class="flex"> | |
<label class="md:w-2/3 flex text-gray-500 font-bold text-sm leading-tight items-center"> | |
<input class="mr-2" type="checkbox" :id="option.id" :value="option" v-model="checkedOptions"> | |
<div class="w-48" v-text="option.description"/> | |
<div class="w-16 text-right" v-text="option.valueDescription"/> | |
</label> | |
</div> | |
</div> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: "CheckBoxGroup", | |
props: ['options'], | |
data() { | |
return { | |
checkedOptions: [] | |
} | |
}, | |
computed: { | |
sum() { | |
return this.checkedOptions.reduce((sum, item) => sum + item.value, 0); | |
} | |
}, | |
} | |
</script> | |
<style scoped> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment