primevue-mirror/src/views/selectbutton/SelectButtonDemo.vue

63 lines
2.2 KiB
Vue
Raw Normal View History

2018-12-15 13:39:00 +00:00
<template>
<div>
<div class="content-section introduction">
<div class="feature-intro">
<h1>SelectButton</h1>
<p>SelectButton is a form component to choose a value from a list of options using button elements.</p>
</div>
</div>
<div class="content-section implementation">
<h3 class="first">Single</h3>
2018-12-31 19:59:02 +00:00
<SelectButton v-model="selectedCity" :options="cities" optionLabel="name" />
<p>Selected City: <span style="font-weight: bold">{{selectedCity}}</span></p>
2018-12-15 13:39:00 +00:00
<h3>Multiple</h3>
2018-12-31 19:59:02 +00:00
<SelectButton v-model="selectedCars" :options="cars" optionLabel="brand" :multiple="true" />
<p>Selected Cars: <span style="font-weight: bold">{{selectedCars}}</span></p>
2018-12-15 13:39:00 +00:00
<h3>Custom Content</h3>
2018-12-31 19:59:02 +00:00
<SelectButton v-model="selectedCar" :options="cars" optionLabel="brand">
2019-03-21 08:32:46 +00:00
<template #option="slotProps">
2018-12-15 13:39:00 +00:00
<div style="text-align: center; padding: 1em; width: 125px">
2019-05-23 14:51:56 +00:00
<img :alt="slotProps.option.brand" :src="'demo/images/car/' + slotProps.option.brand + '.png'" style="width:48px" />
2019-03-21 08:32:46 +00:00
<div style="margin-top: 1em">{{slotProps.option.brand}}</div>
2018-12-15 13:39:00 +00:00
</div>
</template>
2018-12-31 19:59:02 +00:00
</SelectButton>
<p>Selected Car: <span style="font-weight: bold">{{selectedCar}}</span></p>
2018-12-15 13:39:00 +00:00
</div>
2019-03-26 11:52:10 +00:00
<SelectButtonDoc/>
2018-12-15 13:39:00 +00:00
</div>
</template>
<script>
2019-03-26 11:52:10 +00:00
import SelectButtonDoc from './SelectButtonDoc';
2018-12-15 13:39:00 +00:00
export default {
data() {
return {
selectedCity: null,
selectedCar: null,
selectedCars: null,
cities: [
{name: 'London', code: 'LND'},
{name: 'Paris', code: 'PRS'},
{name: 'Rome', code: 'RM'}
],
cars: [
{brand: 'Audi', key: 'A'},
{brand: 'Bmw', key: 'B'},
{brand: 'Mercedes', key: 'M'}
]
}
},
created() {
this.selectedCar = this.cars[1];
2019-03-26 11:52:10 +00:00
},
components: {
'SelectButtonDoc': SelectButtonDoc
2018-12-15 13:39:00 +00:00
}
}
2019-05-25 21:33:37 +00:00
</script>