From b90647d0c114cc647fb9b84fad8f67e51dba9a4c Mon Sep 17 00:00:00 2001 From: Jarinya Date: Mon, 24 Jun 2024 18:16:19 +0700 Subject: [PATCH] fixed bug --- src/components/search/SearchMain.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/search/SearchMain.vue b/src/components/search/SearchMain.vue index def30d2..d388234 100644 --- a/src/components/search/SearchMain.vue +++ b/src/components/search/SearchMain.vue @@ -322,7 +322,8 @@ export default { group: null, offset: 0, count: 0, - searchGroup:null + searchGroup:null, + resultdata:[] }; }, methods: { @@ -378,7 +379,7 @@ export default { const endIndex = startIndex + 10; // ในตัวอย่างนี้ จะใช้ items ของ this.items เป็นตัวอย่าง โดยใช้ฟังก์ชัน slice หรือการดึงข้อมูลจากแหล่งข้อมูล if(this.count>0){ - this.result = [...this.result].slice(startIndex, endIndex); } + this.result = [...this.resultdata].slice(startIndex, endIndex); } // if (offset == 0) { // this.page = 1; @@ -458,11 +459,13 @@ export default { alert("ไม่สามารถโหลดข้อมูลได้"); console.error("เกิดข้อผิดพลาดในการโหลดข้อมูล:", error); }); - + + const startIndex = (this.page - 1) * 10; + const endIndex = startIndex + 10; client.user.getAllUser .query(data) .then((rs) => { - this.result = rs; + this.resultdata = rs; console.log(rs); this.load = false; if (rs.length == 0) { @@ -475,6 +478,11 @@ export default { // alert("ไม่สามารถโหลดข้อมูลได้"); console.error("เกิดข้อผิดพลาดในการโหลดข้อมูล:", error); }); + + // ในตัวอย่างนี้ จะใช้ items ของ this.items เป็นตัวอย่าง โดยใช้ฟังก์ชัน slice หรือการดึงข้อมูลจากแหล่งข้อมูล + if(this.count>0){ + this.result = [...this.resultdata].slice(startIndex, endIndex); } + }, filterData() { // กรองข้อมูลอันที่สองโดยใช้ข้อมูลจากอันแรก