Flatlist ScrollToEnd无法按预期工作

时间:2019-03-02 08:19:45

标签: reactjs react-native

当数据完全加载后,如何滚动到平面列表的底部。

我认为应该可以致电

componentDidMount函数中的

this._flatList.scrollToEnd()。 这对我不起作用。

如果我将该代码用于按钮,那么它将起作用。

然后我认为onLayout = {()=> {console.log(“ onLayout”); this._flatList.scrollToEnd()}可能会有所帮助。但这不是。

1 个答案:

答案 0 :(得分:0)

您可以与计时器配合使用

x = int(input("How many numbers you want to enter?"))
while True:
    attempt = input("Input the numbers seperated with one space")
    try:
        num = [int(val) for val in attempt.split(" ")]
        if len(num)==x:
            print(num)
            break
        else:
            print("You have to enter exactly %s numbers! Try again"%x)
    except:
        print("The given input does not match the format! Try again")
相关问题