list 네이밍 수정

This commit is contained in:
kimdaae328 2025-01-17 16:18:08 +09:00
parent 80f7aff731
commit 5400dea491

View File

@ -59,8 +59,8 @@ import WriteButton from '@c/button/WriteBtn.vue';
import axios from '@api';
//
const list = ref([]);
const list2 = ref([]);
const generalList = ref([]);
const noticeList = ref([]);
const searchText = ref('');
//
@ -75,14 +75,14 @@ const search = (e) => {
// ()
const filteredList = computed(() =>
list.value.filter((item) =>
generalList.value.filter((item) =>
item.title.toLowerCase().includes(searchText.value.toLowerCase())
)
);
// ()
const filteredList2 = computed(() =>
list2.value.filter((item) =>
noticeList.value.filter((item) =>
item.title.toLowerCase().includes(searchText.value.toLowerCase())
)
);
@ -115,7 +115,7 @@ const fetchPosts = async () => {
const response = await axios.get("board/general");
if (response.data && response.data.data && Array.isArray(response.data.data.list)) {
list.value = response.data.data.list.map((post, index) => ({
generalList.value = response.data.data.list.map((post, index) => ({
...post,
id: post.id || index,
img: post.img || null,
@ -128,24 +128,18 @@ const fetchPosts = async () => {
};
const fetchPosts2 = async () => {
try {
console.log('ㅁㄴㅇㅁㅇㅁ')
const response = await axios.get("board/notices");
console.log(response)
const response = await axios.get("board/notices");
if (response.data && response.data.data && Array.isArray(response.data.data)) {
list2.value = response.data.data.map((post, index) => ({
...post,
id: post.id || index,
img: post.img || null,
likes: post.likes || 0,
comments: post.comments || 0,
}));
} else {
console.error("데이터 오류:", response.data);
}
} catch (error) {
console.error("공지사항 데이터 로드 실패:", error);
if (response.data && response.data.data && Array.isArray(response.data.data)) {
noticeList.value = response.data.data.map((post, index) => ({
...post,
id: post.id || index,
img: post.img || null,
likes: post.likes || 0,
comments: post.comments || 0,
}));
} else {
console.error("데이터 오류:", response.data);
}
};