Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H5 SwiperItem会自动增加前后两个dom #8530

Closed
Dlpan opened this issue Jan 14, 2021 · 2 comments
Closed

H5 SwiperItem会自动增加前后两个dom #8530

Dlpan opened this issue Jan 14, 2021 · 2 comments
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-2 Version - 2.x

Comments

@Dlpan
Copy link

Dlpan commented Jan 14, 2021

相关平台

H5

浏览器版本: chrome87
使用框架: React

复现步骤

<Swiper>
    <SwiperItem>
       <View className='demo-text-1'>1</View>
    </SwiperItem>
</Swiper>

期望结果

按实际传的SwiperItem个数展示

实际结果

前后各多了一个swiperItem,如上面的复现步骤上的代码,只传了一个,但实际上渲染出来会有三个。。。。

环境信息

Taro v2.2.16


  Taro CLI 2.2.16 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
      npm: 6.13.4 - ~/.nvm/versions/node/v12.14.1/bin/npm
    npmPackages:
      @tarojs/components: 2.2.16 => 2.2.16 
      @tarojs/mini-runner: ^2.2.16 => 2.2.16 
      @tarojs/plugin-babel: 2.2.16 => 2.2.16 
      @tarojs/plugin-csso: 2.2.16 => 2.2.16 
      @tarojs/plugin-sass: ^2.2.16 => 2.2.16 
      @tarojs/plugin-uglify: ^2.2.10 => 2.2.10 
      @tarojs/router: 2.2.16 => 2.2.16 
      @tarojs/taro: 2.2.16 => 2.2.16 
      @tarojs/taro-alipay: 2.2.16 => 2.2.16 
      @tarojs/taro-h5: 2.2.16 => 2.2.16 
      @tarojs/taro-qq: 2.2.16 => 2.2.16 
      @tarojs/taro-quickapp: 2.2.16 => 2.2.16 
      @tarojs/taro-swan: 2.2.16 => 2.2.16 
      @tarojs/taro-tt: 2.2.16 => 2.2.16 
      @tarojs/taro-weapp: 2.2.16 => 2.2.16 
      @tarojs/webpack-runner: 2.2.16 => 2.2.16 
      eslint-config-taro: 2.2.16 => 2.2.16 
      eslint-plugin-taro: 2.2.16 => 2.2.16 
      nerv-devtools: ^1.5.7 => 1.5.7 
      nervjs: ^1.5.7 => 1.5.7 
      stylelint-config-taro-rn: 2.2.16 => 2.2.16 
      stylelint-taro-rn: 2.2.16 => 2.2.16 
      taro-ui: ^2.2.4 => 2.3.4 

补充信息

看到源码是这样写的:

let items = [].concat(children)
    // 衔接滑动增加首尾
    // if (circular) {
    if (items.length !== 0) {
      const firstItem = items[0]
      const lastItem = items[items.length - 1]
      items.push(firstItem)
      items.unshift(lastItem)
    }

单元测试上的case在验证swiperItem个数的时候也是多了2

@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-2 Version - 2.x labels Jan 14, 2021
@luckyadam
Copy link
Member

用来做无缝滚动的

@Dlpan
Copy link
Author

Dlpan commented Jan 18, 2021

用来做无缝滚动的

@luckyadam
在设置了prevMargin,nextMargin的情况下,原本只写了一个SwiperItem,结果页面上会展示三个SwiperItem,这样跟原本的展示逻辑不符合诶!!而且在只有一个SwiperItem时不可以切换,现在有三个反而可以切换了,这也跟我们想要的效果不一样。

为什么就直接close了

@ZakaryCode ZakaryCode moved this to Done in H5 Apr 10, 2023
@ZakaryCode ZakaryCode added this to H5 Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-2 Version - 2.x
Projects
Archived in project
Development

No branches or pull requests

2 participants