docs_vue2/one/docs/demo/radio/model.vue

48 lines
831 B
Vue
Raw Normal View History

2020-08-13 11:47:56 +08:00
<template>
<article>
<veui-radio
v-for="({ value, label }) in flavors"
:key="value"
v-model="flavor"
:value="value"
>
{{ label }}
</veui-radio>
<p>Selected: {{ flavorLabelMap[flavor] || '-' }}</p>
</article>
</template>
<script>
import { Radio } from 'veui'
export default {
components: {
'veui-radio': Radio
},
data () {
return {
flavor: null,
flavors: [
{ value: 'LATTE', label: 'Latte' },
{ value: 'MOCHA', label: 'Mocha' },
{ value: 'AMERICANO', label: 'Americano' }
]
}
},
computed: {
flavorLabelMap () {
return this.flavors.reduce((map, { value, label }) => {
map[value] = label
return map
}, {})
}
}
}
</script>
<style lang="less" scoped docs>
.veui-radio {
margin-right: 20px;
}
</style>