diff --git a/pages/component/swiper/swiper.test.js b/pages/component/swiper/swiper.test.js index f3d111f153b119ed7119d06a4bfc5ce57bf488ed..449c725ec09c881fee3861db1eda26a1c98c5a29 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 ea75b56f93f207f5bd200dc57e0c60bacaf25fcd..cf1d56ae58e5c09ff8609d82f52f0ccdff64d98b 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)