primevue-mirror/doc/radiobutton/DynamicDoc.vue

92 lines
2.9 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>RadioButtons can be generated using a list of values.</p>
</DocSectionText>
<div class="card flex justify-content-center">
<div class="flex flex-column gap-3">
2023-03-24 07:28:23 +00:00
<div v-for="category in categories" :key="category.key" class="flex align-items-center">
2023-10-02 08:55:02 +00:00
<RadioButton v-model="selectedCategory" :inputId="category.key" name="dynamic" :value="category.name" />
2023-03-24 07:28:23 +00:00
<label :for="category.key" class="ml-2">{{ category.name }}</label>
2023-02-28 08:29:30 +00:00
</div>
</div>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
categories: [
{ name: 'Accounting', key: 'A' },
{ name: 'Marketing', key: 'M' },
{ name: 'Production', key: 'P' },
{ name: 'Research', key: 'R' }
],
selectedCategory: 'Production',
code: {
2023-09-22 12:54:14 +00:00
basic: `
<div v-for="category in categories" :key="category.key" class="flex align-items-center">
2023-10-02 08:55:02 +00:00
<RadioButton v-model="selectedCategory" :inputId="category.key" name="dynamic" :value="category.name" />
2023-02-28 08:29:30 +00:00
<label :for="category.key" class="ml-2">{{ category.name }}</label>
</div>
2023-10-15 09:38:39 +00:00
2023-02-28 08:29:30 +00:00
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card flex justify-content-center">
<div class="flex flex-column gap-3">
2023-03-24 07:28:23 +00:00
<div v-for="category in categories" :key="category.key" class="flex align-items-center">
2023-10-02 08:55:02 +00:00
<RadioButton v-model="selectedCategory" :inputId="category.key" name="dynamic" :value="category.name" />
2023-02-28 08:29:30 +00:00
<label :for="category.key" class="ml-2">{{ category.name }}</label>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
2023-03-24 07:28:23 +00:00
selectedCategory: 'Production',
categories: [
{ name: 'Accounting', key: 'A' },
{ name: 'Marketing', key: 'M' },
{ name: 'Production', key: 'P' },
{ name: 'Research', key: 'R' }
]
2023-02-28 08:29:30 +00:00
}
}
};
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card flex justify-content-center">
<div class="flex flex-column gap-3">
2023-03-24 07:28:23 +00:00
<div v-for="category in categories" :key="category.key" class="flex align-items-center">
2023-10-02 08:55:02 +00:00
<RadioButton v-model="selectedCategory" :inputId="category.key" name="dynamic" :value="category.name" />
2023-02-28 08:29:30 +00:00
<label :for="category.key" class="ml-2">{{ category.name }}</label>
</div>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
2023-03-24 07:28:23 +00:00
const selectedCategory = ref('Production');
const categories = ref([
{ name: 'Accounting', key: 'A' },
{ name: 'Marketing', key: 'M' },
{ name: 'Production', key: 'P' },
{ name: 'Research', key: 'R' }
]);
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
}
};
</script>