From 4c20d30a7b3b8df79769685262a46773c9140a1a Mon Sep 17 00:00:00 2001 From: duqingquan Date: Mon, 25 Sep 2023 19:53:56 +0800 Subject: [PATCH] =?UTF-8?q?swiper=20=E7=A4=BA=E4=BE=8B=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=20current-id=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/swiper/swiper.test.js | 19 ++++++++++++++++--- pages/component/swiper/swiper.uvue | 3 ++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pages/component/swiper/swiper.test.js b/pages/component/swiper/swiper.test.js index f3d111f1..449c725e 100644 --- a/pages/component/swiper/swiper.test.js +++ b/pages/component/swiper/swiper.test.js @@ -53,16 +53,29 @@ describe('test swiper', () => { }); - it('check loop index', async () => { + it('check current', async () => { await page.setData({ currentVal: 2, }) - await page.waitFor(1600) + await page.waitFor(600) expect(await getData('currentValChange')).toEqual(2) await page.setData({ currentVal: 0, }) - await page.waitFor(1600) + await page.waitFor(600) + expect(await getData('currentValChange')).toEqual(0) + }); + + it('check currentId', async () => { + await page.setData({ + currentItemIdVal: 'C', + }) + await page.waitFor(600) + expect(await getData('currentValChange')).toEqual(2) + await page.setData({ + currentItemIdVal: 'A', + }) + await page.waitFor(600) expect(await getData('currentValChange')).toEqual(0) }); diff --git a/pages/component/swiper/swiper.uvue b/pages/component/swiper/swiper.uvue index ea75b56f..cf1d56ae 100644 --- a/pages/component/swiper/swiper.uvue +++ b/pages/component/swiper/swiper.uvue @@ -106,10 +106,11 @@ currentValChange:0 } }, - methods: { + swiperChange: function (e : SwiperChangeEvent) { this.currentValChange = e.detail.current + console.log(this.currentValChange) if (this.swiperChangeSelect) { console.log("swiperChange") console.log(e) -- GitLab