美文网首页React Native学习
react-native 防止重复点击

react-native 防止重复点击

作者: 日不落000 | 来源:发表于2017-10-10 16:41 被阅读1335次

工具类:

NoDoublePress.js

var NoDoublePress = {
    lastPressTime: 1,
    onPress(callback){
        let curTime = new Date().getTime();
        if (curTime - this.lastPressTime > 1000) {
            this.lastPressTime = curTime;
            callback();
        }
    },
};
module.exports = NoDoublePress;

使用方法:

                        <MyButton
                            onPress={() => {
                                NoDoublePress.onPress(() => {
                                    this.onPressLogin();
                                });
                            }}
                        >
                            <Text> 登 录 </Text>
                        </MyButton>

相关文章

网友评论

    本文标题: react-native 防止重复点击

    本文链接:https://www.haomeiwen.com/subject/ifxbyxtx.html