카테고리 버튼 초기화 추가가

This commit is contained in:
khj0414 2025-03-10 16:18:24 +09:00
parent 915e2476e3
commit f70096e975

View File

@ -31,7 +31,7 @@
</template> </template>
<script setup> <script setup>
import { defineProps, ref } from 'vue'; import { defineProps, ref, watch } from 'vue';
// lists prop // lists prop
const props = defineProps({ const props = defineProps({
@ -43,21 +43,29 @@ const props = defineProps({
type: Boolean, type: Boolean,
required: false, required: false,
}, },
selectedCategory: {
type: [String, Number],
default: null,
required: false,
},
}); });
// //
const selectedCategory = ref(null); const selectedCategory = ref(props.selectedCategory);
const emit = defineEmits();
const emit = defineEmits(['update:data']);
const selectCategory = (cate) => { const selectCategory = (cate) => {
selectedCategory.value = selectedCategory.value === cate ? null : cate; selectedCategory.value = selectedCategory.value === cate ? null : cate;
emit('update:data', selectedCategory.value); emit('update:data', selectedCategory.value);
}; };
watch(() => props.selectedCategory, (newVal) => {
selectedCategory.value = newVal;
});
</script> </script>
<style scoped> <style scoped>
@media (max-width: 768px) { @media (max-width: 768px) {
.cate-list { .cate-list {
overflow-x: scroll; overflow-x: scroll;