From 8bea560105492736c5fe8b146f3c675bd343f745 Mon Sep 17 00:00:00 2001 From: ZakaryCode Date: Sat, 7 Nov 2020 00:04:23 +0800 Subject: [PATCH] fix(test): swiper spec --- packages/taro-components/__tests__/swiper.spec.js | 1 + .../taro-components/src/components/swiper/swiper.tsx | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/taro-components/__tests__/swiper.spec.js b/packages/taro-components/__tests__/swiper.spec.js index c5b5c1189480..942ad7436e87 100644 --- a/packages/taro-components/__tests__/swiper.spec.js +++ b/packages/taro-components/__tests__/swiper.spec.js @@ -1,3 +1,4 @@ +import './polyfill' import React from 'react' import * as assert from 'assert' import * as sinon from 'sinon' diff --git a/packages/taro-components/src/components/swiper/swiper.tsx b/packages/taro-components/src/components/swiper/swiper.tsx index f111820a69f0..a214d20998ae 100644 --- a/packages/taro-components/src/components/swiper/swiper.tsx +++ b/packages/taro-components/src/components/swiper/swiper.tsx @@ -14,10 +14,10 @@ let INSTANCE_ID = 0 }) export class Swiper implements ComponentInterface { private _id = INSTANCE_ID++ - private swiper @Element() el: HTMLElement @State() swiperWrapper: HTMLElement | null + @State() private swiper: SwiperJS /** * 是否显示面板指示点 */ @@ -97,7 +97,7 @@ export class Swiper implements ComponentInterface { if (isNaN(n)) return if (this.circular) { - const interval = this.swiper.isBeginning || this.swiper.isBeginning ? this.interval : 0 + const interval = this.swiper.isBeginning || this.swiper.isEnd ? 0 : this.interval this.swiper.slideToLoop(n, interval) // 更新下标 } else { this.swiper.slideTo(n) // 更新下标 @@ -219,11 +219,6 @@ export class Swiper implements ComponentInterface { this.swiper.update() // 更新子元素 } - disconnectedCallback () { - this.swiperWrapper = null - this.swiper.destroy() - } - render () { const { vertical,