From 8aa869f490826da68e98bad60918ca1dc84a67cd Mon Sep 17 00:00:00 2001 From: Eiinu Date: Mon, 20 Nov 2023 22:58:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(swiper):=20=E4=BF=AE=E5=A4=8D=20swiper-item?= =?UTF-8?q?=20=E5=AE=BD=E9=AB=98=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=20(#2?= =?UTF-8?q?679)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/__VUE/address/index.vue | 2 -- .../{index.spec.ts => index.spec.tsx} | 7 ++++--- src/packages/__VUE/swiper/doc.en-US.md | 4 ++-- src/packages/__VUE/swiper/doc.md | 4 ++-- src/packages/__VUE/swiper/doc.taro.md | 4 ++-- src/packages/__VUE/swiper/index.taro.vue | 18 ++++++++---------- src/packages/__VUE/swiper/index.vue | 6 ++---- src/packages/__VUE/video/index.vue | 1 - 8 files changed, 20 insertions(+), 26 deletions(-) rename src/packages/__VUE/swiper/__tests__/{index.spec.ts => index.spec.tsx} (97%) diff --git a/src/packages/__VUE/address/index.vue b/src/packages/__VUE/address/index.vue index 294fba6de0..0a5255b7e6 100644 --- a/src/packages/__VUE/address/index.vue +++ b/src/packages/__VUE/address/index.vue @@ -255,8 +255,6 @@ export default create({ } }); - console.log('new', newData); - return newData; }; diff --git a/src/packages/__VUE/swiper/__tests__/index.spec.ts b/src/packages/__VUE/swiper/__tests__/index.spec.tsx similarity index 97% rename from src/packages/__VUE/swiper/__tests__/index.spec.ts rename to src/packages/__VUE/swiper/__tests__/index.spec.tsx index 0419a7d46c..45f4b62b6a 100644 --- a/src/packages/__VUE/swiper/__tests__/index.spec.ts +++ b/src/packages/__VUE/swiper/__tests__/index.spec.tsx @@ -12,7 +12,7 @@ test('should render width and height', async () => { 'nut-swiper-item': SwiperItem }, template: ` - + @@ -21,7 +21,8 @@ test('should render width and height', async () => { setup() { const state = reactive({ page: 1, - height: '500', + width: 300, + height: 500, list: [ 'https://storage.360buyimg.com/jdc-article/NutUItaro34.jpg', 'https://storage.360buyimg.com/jdc-article/NutUItaro2.jpg', @@ -40,7 +41,7 @@ test('should render width and height', async () => { const swiperItem = wrapper.findAll('.nut-swiper-inner')[0].element as HTMLElement; expect(swiperItem.style.height).toEqual(`${wrapper.vm.height}px`); - expect(swiperItem.style.width).toEqual(`${window.innerWidth * (wrapper.vm.list as any).length}px`); + expect(swiperItem.style.width).toEqual(`${wrapper.vm.width * (wrapper.vm.list as any).length}px`); }); test('should render initpage', async () => { diff --git a/src/packages/__VUE/swiper/doc.en-US.md b/src/packages/__VUE/swiper/doc.en-US.md index b5d81162cc..f3df001c4d 100644 --- a/src/packages/__VUE/swiper/doc.en-US.md +++ b/src/packages/__VUE/swiper/doc.en-US.md @@ -444,8 +444,8 @@ const page = ref(2); | Attribute | Description | Type | Default | | --- | --- | --- | --- | -| width | Width of rotation card | number \| string | `window.innerWidth ` | -| height | Height of rotation card | number \| string | `0` | +| width | Width of rotation card | number \| string | - | +| height | Height of rotation card | number \| string | - | | direction | Rotation direction, optional value:`horizontal`,`vertical` | string | `'horizontal'` | | pagination-visible | Is the paging indicator displayed | boolean | `false` | | pagination-color | The color selected by the pagination indicator | string | `'#fff'` | diff --git a/src/packages/__VUE/swiper/doc.md b/src/packages/__VUE/swiper/doc.md index 2fbd183590..5cd452f97e 100644 --- a/src/packages/__VUE/swiper/doc.md +++ b/src/packages/__VUE/swiper/doc.md @@ -444,8 +444,8 @@ const page = ref(2); | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| width | 轮播卡片的宽度 | number \| string | `window.innerWidth` | -| height | 轮播卡片的高度 | number \| string | `0` | +| width | 轮播卡片的宽度 | number \| string | - | +| height | 轮播卡片的高度 | number \| string | - | | direction | 轮播方向,可选值`horizontal`,`vertical` | string | `'horizontal'` | | pagination-visible | 分页指示器是否展示 | boolean | `false` | | pagination-color | 分页指示器选中的颜色 | string | `'#fff'` | diff --git a/src/packages/__VUE/swiper/doc.taro.md b/src/packages/__VUE/swiper/doc.taro.md index c2e9006a01..176e4c34a8 100644 --- a/src/packages/__VUE/swiper/doc.taro.md +++ b/src/packages/__VUE/swiper/doc.taro.md @@ -435,8 +435,8 @@ const page = ref(2); | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| width | 轮播卡片的宽度 | number \| string | window.innerWidth | -| height | 轮播卡片的高度 | number \| string | `0` | +| width | 轮播卡片的宽度 | number \| string | - | +| height | 轮播卡片的高度 | number \| string | - | | direction | 轮播方向,可选值`horizontal`,`vertical` | string | `'horizontal'` | | pagination-visible | 分页指示器是否展示 | boolean | `false` | | pagination-color | 分页指示器选中的颜色 | string | `'#fff'` | diff --git a/src/packages/__VUE/swiper/index.taro.vue b/src/packages/__VUE/swiper/index.taro.vue index 8936cdda3a..0e3d0a665e 100644 --- a/src/packages/__VUE/swiper/index.taro.vue +++ b/src/packages/__VUE/swiper/index.taro.vue @@ -50,12 +50,10 @@ const { create, componentName } = createComponent('swiper'); export default create({ props: { width: { - type: [Number, String], - default: window.innerWidth + type: [Number, String] }, height: { - type: [Number, String], - default: 0 + type: [Number, String] }, direction: { type: String, @@ -416,24 +414,24 @@ export default create({ watch( () => props.initPage, - () => { + (val) => { Taro.nextTick(() => { - init(); + init(+val); }); eventCenter.once((getCurrentInstance() as any).router.onReady, () => { - init(); + init(+val); }); } ); watch( () => props.height, - (val) => { + () => { Taro.nextTick(() => { - init(+val); + init(); }); eventCenter.once((getCurrentInstance() as any).router.onReady, () => { - init(+val); + init(); }); } ); diff --git a/src/packages/__VUE/swiper/index.vue b/src/packages/__VUE/swiper/index.vue index 16318efee5..1aecd9d931 100644 --- a/src/packages/__VUE/swiper/index.vue +++ b/src/packages/__VUE/swiper/index.vue @@ -47,12 +47,10 @@ const { create, componentName } = createComponent('swiper'); export default create({ props: { width: { - type: [Number, String], - default: window.innerWidth + type: [Number, String] }, height: { - type: [Number, String], - default: 0 + type: [Number, String] }, direction: { type: String, diff --git a/src/packages/__VUE/video/index.vue b/src/packages/__VUE/video/index.vue index 19e9abbb98..090c92a6dc 100644 --- a/src/packages/__VUE/video/index.vue +++ b/src/packages/__VUE/video/index.vue @@ -333,7 +333,6 @@ export default create({ }; const retry = () => { - // console.log('error'); state.state.isError = false; init(); };