usePagination - composition api (vue2)
2022-08-19
이슈 1. 반복 코드 리팩토링
기존 공통 코드
export default Vue.extend({
data: () => ({
pageOptions: {
page: 1,
size: 10,
totalElements: 0,
totalPages: 0,
first: false,
last: false,
},
}),
...
methods: {
async getNotice() {
try {
const response = await notice_api.getNotice(config);
if (response.status === 200) {
const data = response.data.items;
this.pageOptions = {
page: this.pageOptions.page,
size: data.size,
totalElements: data.totalElements,
totalPages: data.totalPages,
first: data.first,
last: data.last,
};
개선 코드
이슈 2. typescript: property does not exist on type 'object & record<never, any>
참고 자료
해결 코드
Pagination 2개 이상 사용시 코드 비교
Last updated