카테고리수정정

This commit is contained in:
khj0414 2025-03-20 10:11:13 +09:00
parent b393a29026
commit f25ad7ffed

View File

@ -5,35 +5,33 @@
type="button" type="button"
class="btn" class="btn"
:class="{ :class="{
'btn-outline-primary': selectedCategory !== 'all', 'btn-outline-primary': selectedCategory !== 'all',
'btn-primary': selectedCategory === 'all' 'btn-primary': selectedCategory === 'all'
}" }"
@click="selectCategory('all')" @click="selectCategory('all')"
> >
All All
</button> </button>
</li> </li>
<li v-for="category in lists" :key="category.value" class="mt-2 me-2"> <li v-for="category in lists" :key="category.value" class="mt-2 me-2">
<button <button
type="button" type="button"
class="btn" class="btn"
:class="{ :class="{
'btn-outline-primary': category.value !== selectedCategory, 'btn-outline-primary': category.value.toString() !== selectedCategory?.toString(),
'btn-primary': category.value === selectedCategory 'btn-primary': category.value.toString() === selectedCategory?.toString()
}" }"
@click="selectCategory(category.value)" @click="selectCategory(category.value)"
> >
{{ category.label }} {{ category.label }}
</button> </button>
</li> </li>
</ul> </ul>
</template> </template>
<script setup> <script setup>
import { defineProps, ref, watch } from 'vue'; import { defineProps, defineEmits, ref, watch } from 'vue';
// lists prop
const props = defineProps({ const props = defineProps({
lists: { lists: {
type: Array, type: Array,
@ -44,7 +42,7 @@ const props = defineProps({
required: false, required: false,
}, },
selectedCategory: { selectedCategory: {
type: [String, Number], type: String,
default: null, default: null,
required: false, required: false,
}, },
@ -63,4 +61,5 @@ watch(() => props.selectedCategory, (newVal) => {
selectedCategory.value = newVal; selectedCategory.value = newVal;
}); });
</script> </script>