const posts = ref();
const count = ref(6);
const postCount = ref();
const isMoreButtonDisabled = ref(false);
const isLoading = ref(false);
const onPostList = async () => {
if (!posts.value || posts.value === undefined) {
isLoading.value = true;
const data = await fetchPostList();
posts.value = data;
postCount.value = await fetchPostCount();
isMoreButtonDisabled.value = posts.value?.length === postCount.value;
isLoading.value = false;
}
};
onMounted(onPostList);
대충이렇게 사용중인데 지금 페이지를벗어났다가 다시들어오면 post.value가 사라지는것같습니다.
어쩌면좋을까요?
컴퓨티드를 적용시켜봤는데 생각만큼 잘안되는데..
적용은 이렇게해봤습니다.
computed(() => {
onPostList();
return posts.value;
});