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的swiper组件绑定了current,当current为0时swiper不切换,其他值可以正常切换 #4492

Closed
gdpu-wxq opened this issue Sep 20, 2019 · 13 comments
Assignees

Comments

@gdpu-wxq
Copy link

gdpu-wxq commented Sep 20, 2019

问题描述
h5环境,swiper组件绑定了current,当current为0时swiper不切换,其他值可以正常切换

复现步骤
[复现问题的步骤]
H5环境,swiper组件绑定了current,动态修改current,当current=0的时候,swiper不切换

期望行为
希望当current为0的时候,切换到相应的swiper

我目前使用的是1.3.18版本,还未解决。
这个是之前的github提出来的
问题的原始链接

@taro-bot
Copy link

taro-bot bot commented Sep 20, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@taro-bot
Copy link

taro-bot bot commented Sep 23, 2019

CC @jinjinjin0731

@jinjinjin0731
Copy link
Contributor

升级到最新试下

@gdpu-wxq
Copy link
Author

还是不行 @jinjinjin0731

@jinjinjin0731
Copy link
Contributor

@gdpu-wxq 贴下代码。 没有复现

@gdpu-wxq
Copy link
Author

import Taro from '@tarojs/taro'
import { Swiper, View, SwiperItem } from '@tarojs/components'
import './index.scss'
interface IState {
    current: number
 }

/**
 * 购物车页面
 */
export default class extends Taro.Component<{}, IState> {
    config: Taro.PageConfig = {
        navigationBarTitleText: '...',
    }

    constructor() {
        super(...arguments)

        this.state = {
            current: 0
        }
    }

    async componentDidShow() {

    }

    goToBefore (current) {
        this.setState({
            current
        })
    }
    render() {
        const {current } = this.state
        return (
            <View>
                <Swiper
                className='test-h'
                indicatorColor='#999'
                indicatorActiveColor='#333'
                vertical
                circular
                indicatorDots
                current={current}
                onChange={(e)=>{this.setState({current:e.detail.current})}}>
                <SwiperItem>
                    <View className='demo-text-1'>1</View>
                </SwiperItem>
                <SwiperItem>
                    <View className='demo-text-2'>2</View>
                </SwiperItem>
                <SwiperItem>
                    <View className='demo-text-3'>3</View>
                </SwiperItem>
            </Swiper>
                <View onClick={ this.goToBefore.bind(this, 0) }>0</View>
                <View onClick={ this.goToBefore.bind(this, 1) }>1</View>
                <View onClick={ this.goToBefore.bind(this, 2) }>2</View>
            
            </View>
            
        )
    }
}

@gdpu-wxq
Copy link
Author

@jinjinjin0731

@BrightTan
Copy link

我也遇到这个问题了,望解决

@BrightTan
Copy link

@jinjinjin0731

@ImPigerla
Copy link

ImPigerla commented Nov 20, 2019

// taro version 1.3.4
// 调用方法,index就是跳转的索引
this.refs.testSwiper.mySwiper.slideTo(index)

// swiper ref
<Swiper ref='testSwiper' ...

@lzt9977
Copy link

lzt9977 commented Jan 7, 2020

确实有这个问题

@sunny2009day
Copy link

多久了,还没解决嘛

@ZakaryCode
Copy link
Contributor

fixed in #b4bb27cc5fc5bda53a0ba53379e9e6078eef942f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants