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

百度小程序 Swiper 中的 onChange 事件会被多次触发,导致 Swiper 不能滑动 #12450

Open
zht0102 opened this issue Sep 7, 2022 · 2 comments
Labels
F-react Framework - React question Further information is requested T-swan Target - 编译到百度小程序 V-3 Version - 3.x

Comments

@zht0102
Copy link

zht0102 commented Sep 7, 2022

相关平台

百度小程序

小程序基础库: 3.540.7
使用框架: React

复现步骤

<Swiper
current={selectIndex}
indicatorDots={false}
autoplay={false}
nextMargin='42px'
onChange={(e) => handleChangeIndex(e)}
>

滑动一次 onChange会多发多次

期望结果

Swpier组件能够正常滑动

实际结果

Swpier组件滑动一下是正常的,后续就无法正常的滑动

环境信息

👽 Taro v3.5.0


  Taro CLI 3.5.0 environment info:
    System:
      OS: macOS 12.0.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.16.1 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 6.14.12 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.4.12 => 3.4.12 
      @tarojs/components: 3.4.12 => 3.4.12 
      @tarojs/mini-runner: 3.4.12 => 3.4.12 
      @tarojs/plugin-framework-react: 3.4.12 => 3.4.12 
      @tarojs/react: 3.4.12 => 3.4.12 
      @tarojs/runtime: 3.4.12 => 3.4.12 
      @tarojs/taro: 3.4.12 => 3.4.12 
      @tarojs/webpack-runner: 3.4.12 => 3.4.12 
      babel-preset-taro: 3.4.12 => 3.4.12 
      eslint-config-taro: 3.4.12 => 3.4.12 
      react: ^17.0.2 => 17.0.2 
    npmGlobalPackages:
      typescript: 4.7.4


@taro-bot2 taro-bot2 bot added F-react Framework - React T-swan Target - 编译到百度小程序 V-3 Version - 3.x labels Sep 7, 2022
@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 19, 2022

@zht0102 麻烦提供一下完整 demo

@Chen-jj Chen-jj added the question Further information is requested label Sep 19, 2022
@zht0102
Copy link
Author

zht0102 commented Sep 21, 2022

@zht0102 麻烦提供一下完整 demo

<Swiper
current={selectIndex}
indicatorDots={false}
autoplay={false}
nextMargin='42px'
onChange={(e) => handleChangeIndex(e)}

这样写就可以复现,不过这个问题我已经解决了 要在config加配置 如下:
['@tarojs/plugin-inject', {
components: {
Swiper: {
displayMultipleItems: "1",
},
}
}
]

应该是这个属性引起的问题 displayMultipleItems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React question Further information is requested T-swan Target - 编译到百度小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants