【问题标题】:How to scroll down ListView to the bottom of it after button tapping (using scrollToIndex for instance)? NativeScript-Vue点击按钮后如何将ListView向下滚动到底部(例如使用scrollToIndex)? NativeScript-Vue
【发布时间】:2019-10-01 18:33:20
【问题描述】:

也许这似乎是一件容易的事,但我真的不知道如何解决它。

我的 NativeScript-vue 应用程序中有一个 ListView 组件。在我点击一个按钮后,我需要 ListView 向下滚动到它的末尾。

我试过了:

<ListView ref="listViewEl" for="item in items">
<TextView :text="item.value"></TextView>
</ListView>
...

tappingButton() {
    this.$refs.listViewEl.scrollIndexTo(lastIndexScroll);
}

但它不起作用,我收到一个错误:

this.$refs.listViewEl.scrollToIndex 不是函数。

它也不适用于“scrollTo、smoothScrollToPosition、scrollToVerticalOffset 等”等其他方法。

我错过了什么?

提前谢谢你。

【问题讨论】:

    标签: javascript listview nativescript nativescript-vue nativescript-telerik-ui


    【解决方案1】:

    您缺少.nativeView。为了从引用中访问实际的ListView 元素,您必须调用.nativeView 属性。

    tappingButton() {
       this.$refs.listViewEl.nativeView.scrollToIndex(lastIndexScroll);
    }
    

    方法名也是scrollToIndex

    【讨论】:

      猜你喜欢
      • 2018-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-04
      • 2017-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多